Minor GUI tweaking - Alex
authorterminatorX <>
Sun, 24 Nov 2002 17:21:59 +0000 (17:21 +0000)
committerterminatorX <>
Sun, 24 Nov 2002 17:21:59 +0000 (17:21 +0000)
src/tX_mastergui.cc
src/tX_panel.cc
src/tX_panel.h
src/tX_pbutton.cc
src/tX_vttgui.cc

index 49d5e28a34866c92a3f62b3afb5e021999f3ff8c..3174d4ae7c8f2bb053ff522314a9d2e749e1a820 100644 (file)
@@ -801,6 +801,7 @@ void sequencer_move(GtkWidget *wid, void *d)
 
 void fullscreen_toggle(GtkCheckMenuItem *item, gpointer data);
 void display_help();
+void display_browser();
 
 void create_master_menu() {
        GtkWidget *menu_item;
@@ -918,7 +919,7 @@ void create_master_menu() {
        menu_item = gtk_menu_item_new_with_mnemonic ("_Visit terminatorX.cx");
        gtk_widget_show (menu_item);
        gtk_container_add (GTK_CONTAINER (sub_menu), menu_item);
-       //g_signal_connect(menu_item, "activate", (GCallback) mplcfitx, NULL);
+       g_signal_connect(menu_item, "activate", (GCallback) display_browser, NULL);
 }
 
 void create_mastergui(int x, int y)
@@ -1095,7 +1096,9 @@ void create_mastergui(int x, int y)
 
        /* Master */
        
-       dummy=gtk_label_new("Master");
+       dummy=gtk_label_new(NULL);
+       //gtk_label_set_markup(GTK_LABEL(dummy),"<span foreground='#000080'>Master</span>");
+       gtk_label_set_markup(GTK_LABEL(dummy),"<b>Master</b>");
        gtk_misc_set_alignment(GTK_MISC(dummy), 0.5, 0.5);
        gtk_box_pack_start(GTK_BOX(right_hbox), dummy, WID_FIX);
        gtk_widget_show(dummy); 
@@ -1205,7 +1208,8 @@ void create_mastergui(int x, int y)
        
        add_sep2();
 
-       dummy=gtk_label_new("Status:");
+       dummy=gtk_label_new(NULL);
+       gtk_label_set_markup(GTK_LABEL(dummy), "<b>Status</b>");
        gtk_misc_set_alignment(GTK_MISC(dummy), 0.5, 0.5);
        gtk_box_pack_end(GTK_BOX(status_box), dummy, WID_FIX);
        gtk_widget_show(dummy);
@@ -1406,3 +1410,59 @@ void display_help() {
                help_tag=gtk_idle_add((GtkFunction) help_checker, NULL);
        }
 }
+
+pid_t browser_child=0;
+GTimer *browser_timer=NULL;
+int browser_tag=-1;
+
+int browser_checker() {
+       gdouble time;
+       gulong ms;
+       int status;
+       int result=waitpid(browser_child, &status, WNOHANG);
+       
+       if (result==0) {
+               time=g_timer_elapsed(browser_timer, &ms);
+               if (time > 5) {
+                       /* 5 seconds and it's still running - so we assume everything's OK. */
+                       tX_debug("No longer waiting for a browser..");
+                       gtk_idle_remove(browser_tag);
+                       browser_tag=-1;
+               }
+       } else {
+               /* We are still here and the child exited - that could mean trouble. */
+               tx_note("Failed to run a suitable web browser - if there's one installed on this system, please run it and forward yourself to:\nhttp://terminatorX.cx", true);         
+               
+               gtk_idle_remove(browser_tag);
+               browser_tag=-1;
+       }
+       return TRUE;    
+}
+
+void display_browser() {       
+       browser_child=fork();
+
+       if (browser_tag!=-1) {
+               gtk_idle_remove(browser_tag);
+               if (browser_timer) g_timer_destroy(browser_timer);
+               browser_child=0;
+               browser_tag=-1;
+               browser_timer=NULL;
+       }
+       
+       if (browser_child==0) {
+               // child
+               execlp("mozilla","mozilla","http://terminatorX.cx", NULL);
+               execlp("netscape","netscape","http://terminatorX.cx", NULL);
+               execlp("galeon","galeon","http://terminatorX.cx", NULL);
+               execlp("konqueror","konqueror","http://terminatorX.cx", NULL);          
+               _exit(-1);
+       } else if (browser_child==-1) {
+               tx_note("System error: couldn't fork() to run the browser process.", true);
+       } else {
+               browser_timer=g_timer_new();
+               g_timer_start(browser_timer);
+       
+               browser_tag=gtk_idle_add((GtkFunction) browser_checker, NULL);
+       }
+}
index f584c36577da9bb40584b2ed8deb59b3658490a5..76728606e5c886e2e5cd153ec5c0ec5e19599c86 100644 (file)
@@ -1,6 +1,6 @@
 #include "tX_panel.h"
 #include "tX_pbutton.h"
-
+#include <string.h>
 #include <stdio.h>
 
 #define WID_DYN TRUE, TRUE, 0
@@ -39,6 +39,14 @@ void tX_panel :: minimize(GtkWidget *w, tX_panel *p)
        }
 }
 
+void tX_panel_make_label_bold(GtkWidget *widget) {
+       char label[128];
+       strcpy(label, "<b>");
+       strcat(label, gtk_label_get_text(GTK_LABEL(widget)));
+       strcat(label, "</b>");
+       gtk_label_set_markup(GTK_LABEL (widget), label);
+}
+
 tX_panel :: tX_panel (const char *name, GtkWidget *par)
 {
        GtkWidget *pixmap;
@@ -49,7 +57,7 @@ tX_panel :: tX_panel (const char *name, GtkWidget *par)
        pixmap=tx_pixmap_widget(TX_ICON_MINIMIZE);
        gtk_container_add (GTK_CONTAINER (minbutton), pixmap);
        labelbutton=gtk_button_new_with_label(name);
-       
+       gtk_container_foreach(GTK_CONTAINER(labelbutton), (GtkCallback) tX_panel_make_label_bold, NULL);
        mainbox=gtk_vbox_new(FALSE, 0);
        
        topbox=gtk_hbox_new(FALSE, 0);
index 2484686fb96fb1eaa8908ff567b495cfda65cad3..010c499bc5baf1c8e13416ad005726e32b39a197 100644 (file)
@@ -28,4 +28,5 @@ class tX_panel
        static void minimize(GtkWidget *w, tX_panel *p);
 };
 
+extern void tX_panel_make_label_bold(GtkWidget *widget);
 #endif
index 5c3f702793e629861cc702f44aa035989a54802e..b14fcc824c567781f73e679340519ba4c269f70f 100644 (file)
@@ -77,29 +77,30 @@ GtkWidget *tx_xpm_label_box(int     icon_id, gchar *label_text, GtkWidget **labelwid
     GtkWidget *box1;
     GtkWidget *label;
     GtkWidget *pixmapwid;
-
-    /* Create box for xpm and label */
-    box1 = gtk_hbox_new (FALSE, 0);
-       gtk_container_set_border_width (GTK_CONTAINER (box1), 0);
        
-    if (globals.button_type != BUTTON_TYPE_TEXT)
-    {
-           pixmapwid=tx_pixmap_widget(icon_id);
-           gtk_box_pack_start (GTK_BOX (box1), pixmapwid, FALSE, FALSE, 0);
-           gtk_widget_show(pixmapwid);
-    }
-
-    if ((globals.button_type != BUTTON_TYPE_ICON) || (labelwidget!=NULL))
-    {
-           label = gtk_label_new (label_text);
-           gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
-           gtk_widget_show(label); 
-               if (labelwidget!=NULL) {
-                       *labelwidget=label;
-               }
-    }
-
-    return(box1);
+       switch (globals.button_type) {
+               case BUTTON_TYPE_TEXT:
+                       label = gtk_label_new(label_text);
+                       gtk_widget_show(label);
+                       if (labelwidget!=NULL) *labelwidget=label;
+                       return label;
+                       break;
+               case BUTTON_TYPE_ICON:
+                       pixmapwid=tx_pixmap_widget(icon_id);
+                       gtk_widget_show(pixmapwid);
+                       return pixmapwid;
+                       break;
+               default:
+                       box1 = gtk_hbox_new (FALSE, 2);
+                       pixmapwid=tx_pixmap_widget(icon_id);
+                       gtk_box_pack_start (GTK_BOX (box1), pixmapwid, FALSE, FALSE, 0);
+                       gtk_widget_show(pixmapwid);
+                       label = gtk_label_new (label_text);
+                       gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
+                       gtk_widget_show(label); 
+                       if (labelwidget!=NULL)  *labelwidget=label;
+                       return box1;
+       }    
 }
 
 //GtkWidget *tx_xpm_button_new(int icon_id, char *label, int toggle)
@@ -113,7 +114,7 @@ extern GtkWidget *tx_xpm_button_new(int icon_id, char *label, int toggle, GtkWid
        
        box=tx_xpm_label_box(icon_id, label, labelwidget);
        gtk_widget_show(box);
-    gtk_container_set_border_width (GTK_CONTAINER (button), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (button), 3);
        gtk_container_add (GTK_CONTAINER (button), box);                
        
        return(button);
index 50311c87d84fd395642962761701955240242fa1..e4caaf2815da676b2194578567365b8478c27182 100644 (file)
@@ -670,6 +670,26 @@ void fx_button_pressed(GtkWidget *wid, vtt_class *vtt)
        gtk_signal_emit_by_name(GTK_OBJECT(wid), "released", vtt);
 }
 
+void gui_set_name(vtt_class *vtt, char *newname)
+{
+       char bold_name[128];
+       strcpy(bold_name, "<b>");
+       strcat(bold_name, newname);
+       strcat(bold_name, "</b>");
+       
+       gtk_label_set_markup(GTK_LABEL(vtt->gui.audio_label), bold_name);
+       gtk_label_set_markup(GTK_LABEL(vtt->gui.control_label), bold_name);
+       gtk_entry_set_text(GTK_ENTRY(vtt->gui.name), newname);
+       
+       if (vtt->gui.audio_minimized_panel_bar_button!=NULL) {
+               gtk_label_set_text(GTK_LABEL(vtt->gui.audio_minimized_panel_bar_label), newname);
+       }
+
+       if (vtt->gui.control_minimized_panel_bar_button!=NULL) {
+               gtk_label_set_text(GTK_LABEL(vtt->gui.control_minimized_panel_bar_label), newname);
+       }
+}
+
 #define connect_entry(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "activate", (GtkSignalFunc) func, (void *) vtt);
 #define connect_adj(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "value_changed", (GtkSignalFunc) func, (void *) vtt);
 #define connect_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "clicked", (GtkSignalFunc) func, (void *) vtt);
@@ -906,6 +926,7 @@ void build_vtt_gui(vtt_class *vtt)
        gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
 
        dummy=gtk_button_new_with_label("FX");
+       gtk_container_foreach(GTK_CONTAINER(dummy), (GtkCallback) tX_panel_make_label_bold, NULL);
        gtk_widget_show(dummy);
        g->fx_button=dummy;
        gui_set_tooltip(g->fx_button, "Click here to load a LADSPA plugin. You will get a menu from which you can choose which plugin to load.");
@@ -1011,7 +1032,7 @@ void build_vtt_gui(vtt_class *vtt)
        gtk_box_pack_start(GTK_BOX(tempbox3), g->solo, WID_FIX);
        gtk_signal_connect(GTK_OBJECT(g->solo),"clicked", (GtkSignalFunc) solo_vtt, vtt);
        gtk_widget_show(g->solo);
-       gui_set_tooltip(g->mute, "Allow only this and other solo-switched turntabels' signal to be routed to the mixer.");
+       gui_set_tooltip(g->solo, "Allow only this and other solo-switched turntabels' signal to be routed to the mixer.");
 
        gtk_box_pack_start(GTK_BOX(tempbox2), tempbox3, WID_FIX);
 
@@ -1041,6 +1062,8 @@ void build_vtt_gui(vtt_class *vtt)
        g->mouse_mapping_menu=NULL;
        g->mouse_mapping_menu_x=NULL;
        g->mouse_mapping_menu_y=NULL;
+       
+       gui_set_name(vtt, vtt->name);
 }
 
 void fx_up(GtkWidget *wid, vtt_fx *effect)
@@ -1177,21 +1200,6 @@ void vg_create_fx_gui(vtt_class *vtt, vtt_fx_ladspa *effect, LADSPA_Plugin *plug
        gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
 }
 
-void gui_set_name(vtt_class *vtt, char *newname)
-{
-       gtk_label_set_text(GTK_LABEL(vtt->gui.audio_label), newname);
-       gtk_label_set_text(GTK_LABEL(vtt->gui.control_label), newname);
-       gtk_entry_set_text(GTK_ENTRY(vtt->gui.name), newname);
-       
-       if (vtt->gui.audio_minimized_panel_bar_button!=NULL) {
-               gtk_label_set_text(GTK_LABEL(vtt->gui.audio_minimized_panel_bar_label), newname);
-       }
-
-       if (vtt->gui.control_minimized_panel_bar_button!=NULL) {
-               gtk_label_set_text(GTK_LABEL(vtt->gui.control_minimized_panel_bar_label), newname);
-       }
-}
-
 void gui_set_filename (vtt_class *vtt, char *newname)
 {
         gtk_button_set_label(GTK_BUTTON(vtt->gui.file), newname);