changeset 33538:64e43eb13ebf

Cosmetic: Format to MPlayer coding style.
author ib
date Thu, 16 Jun 2011 12:30:24 +0000
parents cceb74e98445
children 5bdc088113f7
files gui/mplayer/widgets.c gui/mplayer/widgets.h
diffstat 2 files changed, 199 insertions(+), 169 deletions(-) [+]
line wrap: on
line diff
--- a/gui/mplayer/widgets.c	Thu Jun 16 11:52:44 2011 +0000
+++ b/gui/mplayer/widgets.c	Thu Jun 16 12:30:24 2011 +0000
@@ -42,18 +42,17 @@
 #include "gui/interface.h"
 #include "gui/wm/ws.h"
 
-
 #include "play.h"
 #include "gtk/fs.h"
 
-GtkWidget     * PopUpMenu = NULL;
+GtkWidget *PopUpMenu = NULL;
 
-GtkWidget     * WarningPixmap;
-GtkWidget     * ErrorPixmap;
+GtkWidget *WarningPixmap;
+GtkWidget *ErrorPixmap;
 
-int gtkPopupMenu = 0;
+int gtkPopupMenu      = 0;
 int gtkPopupMenuParam = 0;
-int gtkInitialized = 0;
+int gtkInitialized    = 0;
 
 #include "gtk/sb.h"
 #include "gtk/pl.h"
@@ -71,190 +70,221 @@
 
 guiIcon_t guiIcon;
 
-void gtkInit( void )
+void gtkInit(void)
 {
- int argc = 0;
- char *arg[3], **argv = arg;
- GdkPixmap *gdkIcon;
- GdkBitmap *gdkIconMask;
+    int argc = 0;
+    char *arg[3], **argv = arg;
+    GdkPixmap *gdkIcon;
+    GdkBitmap *gdkIconMask;
 
- mp_msg( MSGT_GPLAYER,MSGL_V,"GTK init.\n" );
+    mp_msg(MSGT_GPLAYER, MSGL_V, "GTK init.\n");
 
- arg[argc++] = GMPlayer;
+    arg[argc++] = GMPlayer;
 
- if (mDisplayName)                 // MPlayer option '-display' was given
- {
-   arg[argc++] = "--display";      // Pass corresponding command line arguments to GTK,
-   arg[argc++] = mDisplayName;     // to open the requested display for the GUI, too.
- }
+    if (mDisplayName) {            // MPlayer option '-display' was given
+        arg[argc++] = "--display"; // Pass corresponding command line arguments to GTK,
+        arg[argc++] = mDisplayName; // to open the requested display for the GUI, too.
+    }
 
 #ifdef CONFIG_GTK2
- gtk_disable_setlocale();
+    gtk_disable_setlocale();
 #endif
 
- gtk_init( &argc, &argv );
+    gtk_init(&argc, &argv);
+
+    gdkIcon = gdk_pixmap_colormap_create_from_xpm_d(NULL, gdk_colormap_get_system(), &gdkIconMask, NULL, (gchar **)mplayer_xpm);
 
- gdkIcon=gdk_pixmap_colormap_create_from_xpm_d( NULL,gdk_colormap_get_system(),&gdkIconMask,NULL,(gchar **) mplayer_xpm );
+    // start up GTK which realizes the pixmaps
+    gtk_main_iteration_do(FALSE);
+
+    guiIcon.normal      = GDK_PIXMAP_XID(gdkIcon);
+    guiIcon.normal_mask = GDK_PIXMAP_XID(gdkIconMask);
 
- // start up GTK which realizes the pixmaps
- gtk_main_iteration_do(FALSE);
+    gtkInitialized = 1;
+}
 
- guiIcon.normal=GDK_PIXMAP_XID( gdkIcon );
- guiIcon.normal_mask=GDK_PIXMAP_XID( gdkIconMask );
+void gtkAddIcon(GtkWidget *window)
+{
+    wsSetIcon(gdk_display, GDK_WINDOW_XWINDOW(window->window), &guiIcon);
+}
 
- gtkInitialized=1;
+void gtkClearList(GtkWidget *list)
+{
+    gtk_clist_clear(GTK_CLIST(list));
 }
 
-void gtkAddIcon( GtkWidget * window )
-{ wsSetIcon( gdk_display,GDK_WINDOW_XWINDOW( window->window ),&guiIcon ); }
-
-void gtkClearList( GtkWidget * list )
-{ gtk_clist_clear( GTK_CLIST( list ) ); }
-
-int gtkFindCList( GtkWidget * list,char * item )
+int gtkFindCList(GtkWidget *list, char *item)
 {
- gint    j;
- gchar * tmpstr;
- for( j=0;j<GTK_CLIST( list )->rows;j++ )
-  {
-   gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
-   if ( !strcmp( tmpstr,item ) ) return j;
-  }
- return -1;
+    gint j;
+    gchar *tmpstr;
+
+    for (j = 0; j < GTK_CLIST(list)->rows; j++) {
+        gtk_clist_get_text(GTK_CLIST(list), j, 0, &tmpstr);
+
+        if (!strcmp(tmpstr, item))
+            return j;
+    }
+
+    return -1;
 }
 
-void gtkSetDefaultToCList( GtkWidget * list,char * item )
+void gtkSetDefaultToCList(GtkWidget *list, char *item)
 {
- gint    i;
- if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
+    gint i;
+
+    if ((i = gtkFindCList(list, item)) > -1)
+        gtk_clist_select_row(GTK_CLIST(list), i, 0);
 }
 
-void gtkEventHandling( void )
+void gtkEventHandling(void)
 {
- int i;
- for( i=0;i < 25;i++ ) gtk_main_iteration_do( 0 );
+    int i;
+
+    for (i = 0; i < 25; i++)
+        gtk_main_iteration_do(0);
 }
 
 // --- funcs
 
-void gtkMessageBox( int type,const gchar * str )
+void gtkMessageBox(int type, const gchar *str)
 {
- if ( !gtkInitialized ) return;
- ShowMessageBox( str );
- gtk_label_set_text( GTK_LABEL( gtkMessageBoxText ),str );
- /* enable linewrapping by alex */
+    if (!gtkInitialized)
+        return;
+
+    ShowMessageBox(str);
+    gtk_label_set_text(GTK_LABEL(gtkMessageBoxText), str);
+
+    /* enable linewrapping by alex */
 // GTK_LABEL(gtkMessageBoxText)->max_width = 80;
- if (strlen(str) > 80)
-    gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE);
- else
-    gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE);
- switch( type)
-  {
+    if (strlen(str) > 80)
+        gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), TRUE);
+    else
+        gtk_label_set_line_wrap(GTK_LABEL(gtkMessageBoxText), FALSE);
+
+    switch (type) {
     case GTK_MB_FATAL:
-         gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_FatalError );
-         gtk_widget_hide( WarningPixmap );
-         gtk_widget_show( ErrorPixmap );
-         break;
+        gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_MSGBOX_LABEL_FatalError);
+        gtk_widget_hide(WarningPixmap);
+        gtk_widget_show(ErrorPixmap);
+        break;
+
     case GTK_MB_ERROR:
-         gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Error );
-         gtk_widget_hide( WarningPixmap );
-         gtk_widget_show( ErrorPixmap );
-         break;
+        gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_MSGBOX_LABEL_Error);
+        gtk_widget_hide(WarningPixmap);
+        gtk_widget_show(ErrorPixmap);
+        break;
+
     case GTK_MB_WARNING:
-         gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Warning );
-         gtk_widget_show( WarningPixmap );
-         gtk_widget_hide( ErrorPixmap );
-         break;
-  }
- gtk_widget_show( MessageBox );
- gtkSetLayer( MessageBox );
- if ( type == GTK_MB_FATAL )
-  while ( MessageBox ) gtk_main_iteration_do( 0 );
+        gtk_window_set_title(GTK_WINDOW(MessageBox), MSGTR_MSGBOX_LABEL_Warning);
+        gtk_widget_show(WarningPixmap);
+        gtk_widget_hide(ErrorPixmap);
+        break;
+    }
+
+    gtk_widget_show(MessageBox);
+    gtkSetLayer(MessageBox);
+
+    if (type == GTK_MB_FATAL)
+        while (MessageBox)
+            gtk_main_iteration_do(0);
 }
 
-void gtkSetLayer( GtkWidget * wdg )
+void gtkSetLayer(GtkWidget *wdg)
 {
- wsSetLayer( gdk_display,GDK_WINDOW_XWINDOW( wdg->window ),appMPlayer.subWindow.isFullScreen );
- gtkActive( wdg );
+    wsSetLayer(gdk_display, GDK_WINDOW_XWINDOW(wdg->window), appMPlayer.subWindow.isFullScreen);
+    gtkActive(wdg);
+}
+
+void gtkActive(GtkWidget *wdg)
+{
+    wsMoveTopWindow(gdk_display, GDK_WINDOW_XWINDOW(wdg->window));
 }
 
-void gtkActive( GtkWidget * wdg )
-{ wsMoveTopWindow( gdk_display,GDK_WINDOW_XWINDOW( wdg->window )); }
-
-void gtkShow( int type,char * param )
+void gtkShow(int type, char *param)
 {
- switch( type )
-  {
-   case evEqualizer:
-	ShowEqualizer();
-	gtkSetLayer( Equalizer );
-	break;
-   case evSkinBrowser:
-	ShowSkinBrowser();
+    switch (type) {
+    case evEqualizer:
+        ShowEqualizer();
+        gtkSetLayer(Equalizer);
+        break;
+
+    case evSkinBrowser:
+        ShowSkinBrowser();
+
 //        gtkClearList( SkinList );
-        if ( gtkFillSkinList( sbMPlayerPrefixDir ) &&
-             gtkFillSkinList( sbMPlayerDirInHome ) )
-         {
-          gtkSetDefaultToCList( SkinList,param );
-	  gtk_clist_sort( GTK_CLIST( SkinList ) );
-          gtk_widget_show( SkinBrowser );
-	  gtkSetLayer( SkinBrowser );
-         }
-	 else
-	  {
-	   gtk_widget_destroy( SkinBrowser );
-	   gtkMessageBox( GTK_MB_ERROR,"Skin dirs not found ... Please install skins." );
-	  }
+        if (gtkFillSkinList(sbMPlayerPrefixDir) &&
+            gtkFillSkinList(sbMPlayerDirInHome)) {
+            gtkSetDefaultToCList(SkinList, param);
+            gtk_clist_sort(GTK_CLIST(SkinList));
+            gtk_widget_show(SkinBrowser);
+            gtkSetLayer(SkinBrowser);
+        } else {
+            gtk_widget_destroy(SkinBrowser);
+            gtkMessageBox(GTK_MB_ERROR, "Skin dirs not found ... Please install skins.");
+        }
+
         break;
-   case evPreferences:
+
+    case evPreferences:
         ShowPreferences();
         break;
-   case evPlayList:
+
+    case evPlayList:
         ShowPlayList();
-	gtkSetLayer( PlayList );
+        gtkSetLayer(PlayList);
         break;
-   case evLoad:
-        ShowFileSelect( fsVideoSelector,0 );
-	gtkSetLayer( fsFileSelect );
+
+    case evLoad:
+        ShowFileSelect(fsVideoSelector, 0);
+        gtkSetLayer(fsFileSelect);
         break;
-   case evFirstLoad:
-        ShowFileSelect( fsVideoSelector,0 );
-	gtkSetLayer( fsFileSelect );
+
+    case evFirstLoad:
+        ShowFileSelect(fsVideoSelector, 0);
+        gtkSetLayer(fsFileSelect);
         break;
-   case evLoadSubtitle:
-        ShowFileSelect( fsSubtitleSelector,0 );
-	gtkSetLayer( fsFileSelect );
+
+    case evLoadSubtitle:
+        ShowFileSelect(fsSubtitleSelector, 0);
+        gtkSetLayer(fsFileSelect);
         break;
-   case evLoadAudioFile:
-	ShowFileSelect( fsAudioSelector,0 );
-	gtkSetLayer( fsFileSelect );
-	break;
-   case evAbout:
-	ShowAboutBox();
-	gtkSetLayer( About );
+
+    case evLoadAudioFile:
+        ShowFileSelect(fsAudioSelector, 0);
+        gtkSetLayer(fsFileSelect);
+        break;
+
+    case evAbout:
+        ShowAboutBox();
+        gtkSetLayer(About);
         break;
-   case evShowPopUpMenu:
-        gtkPopupMenu=evNone;
-        gtkPopupMenuParam=0;
-        if ( PopUpMenu )
-	 {
-	  gtk_widget_hide( PopUpMenu );
-	  gtk_widget_destroy( PopUpMenu );
-	 }
-        PopUpMenu=create_PopUpMenu();
-        gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 );
+
+    case evShowPopUpMenu:
+        gtkPopupMenu      = evNone;
+        gtkPopupMenuParam = 0;
+
+        if (PopUpMenu) {
+            gtk_widget_hide(PopUpMenu);
+            gtk_widget_destroy(PopUpMenu);
+        }
+
+        PopUpMenu = create_PopUpMenu();
+        gtk_menu_popup(GTK_MENU(PopUpMenu), NULL, NULL, NULL, NULL, 0, 0);
         break;
-   case evHidePopUpMenu:
-        if ( PopUpMenu )
-	 {
-	  gtk_widget_hide( PopUpMenu );
-	  gtk_widget_destroy( PopUpMenu );
-	  PopUpMenu=NULL;
-	 }
+
+    case evHidePopUpMenu:
+
+        if (PopUpMenu) {
+            gtk_widget_hide(PopUpMenu);
+            gtk_widget_destroy(PopUpMenu);
+            PopUpMenu = NULL;
+        }
+
         break;
-   case evPlayNetwork:
-	ShowURLDialogBox();
-	gtkSetLayer( URL );
-	break;
-  }
+
+    case evPlayNetwork:
+        ShowURLDialogBox();
+        gtkSetLayer(URL);
+        break;
+    }
 }
--- a/gui/mplayer/widgets.h	Thu Jun 16 11:52:44 2011 +0000
+++ b/gui/mplayer/widgets.h	Thu Jun 16 12:30:24 2011 +0000
@@ -37,44 +37,44 @@
 #define GTK_MB_ERROR 4
 #define GTK_MB_WARNING 8
 
-extern GtkWidget     * PlayList;
-extern GtkWidget     * Options;
-extern GtkWidget     * PopUpMenu;
+extern GtkWidget *PlayList;
+extern GtkWidget *Options;
+extern GtkWidget *PopUpMenu;
 
-extern GtkWidget     * WarningPixmap;
-extern GtkWidget     * ErrorPixmap;
+extern GtkWidget *WarningPixmap;
+extern GtkWidget *ErrorPixmap;
 
-extern GtkWidget     * SkinList;
-extern GtkWidget     * gtkMessageBoxText;
+extern GtkWidget *SkinList;
+extern GtkWidget *gtkMessageBoxText;
 
-extern int             gtkPopupMenu;
-extern int             gtkPopupMenuParam;
+extern int gtkPopupMenu;
+extern int gtkPopupMenuParam;
 
-extern char          * sbMPlayerDirInHome;
-extern char          * sbMPlayerPrefixDir;
+extern char *sbMPlayerDirInHome;
+extern char *sbMPlayerPrefixDir;
 
 typedef struct {
-  Pixmap normal;
-  Pixmap normal_mask;
+    Pixmap normal;
+    Pixmap normal_mask;
 } guiIcon_t;
 
 extern guiIcon_t guiIcon;
 
-void widgetsCreate( void );
+void widgetsCreate(void);
 
-void gtkInit( void );
-void gtkAddIcon( GtkWidget * window );
+void gtkInit(void);
+void gtkAddIcon(GtkWidget *window);
 
-int  gtkFillSkinList( gchar * dir );
-void gtkClearList( GtkWidget * list );
-void gtkSetDefaultToCList( GtkWidget * list, char * item );
-int  gtkFindCList( GtkWidget * list, char * item );
+int gtkFillSkinList(gchar *dir);
+void gtkClearList(GtkWidget *list);
+void gtkSetDefaultToCList(GtkWidget *list, char *item);
+int gtkFindCList(GtkWidget *list, char *item);
 
-void gtkEventHandling( void );
+void gtkEventHandling(void);
 
-void gtkShow( int type, char * param );
-void gtkMessageBox( int type, const gchar * str );
-void gtkSetLayer( GtkWidget * wdg );
-void gtkActive( GtkWidget * wdg );
+void gtkShow(int type, char *param);
+void gtkMessageBox(int type, const gchar *str);
+void gtkSetLayer(GtkWidget *wdg);
+void gtkActive(GtkWidget *wdg);
 
 #endif /* MPLAYER_GUI_WIDGETS_H */