Index: separator.c =================================================================== --- separator.c (révision 25848) +++ separator.c (copie de travail) @@ -33,9 +33,14 @@ #define SEPARATOR_WIDTH 10 #define SEP_START 0.15 #define SEP_END 0.85 +#define SEP_EMPTY 0 +#define SEP_EXPAND 1 +#define SEP_LINE 2 +#define SEP_HANDLE 3 static void separator_properties_dialog (XfcePanelPlugin *plugin); - +/* a line by default */ +static int separator_type = SEP_LINE; static void separator_construct (XfcePanelPlugin *plugin); /* -------------------------------------------------------------------- * @@ -57,29 +62,40 @@ { GtkAllocation *allocation = &(widget->allocation); int start, end, position; - - if (xfce_panel_plugin_get_orientation (plugin) == - GTK_ORIENTATION_HORIZONTAL) + switch (separator_type) { - start = allocation->y + SEP_START * allocation->height; - end = allocation->y + SEP_END * allocation->height; - position = allocation->x + allocation->width / 2; + case SEP_LINE: + if (xfce_panel_plugin_get_orientation (plugin) == + GTK_ORIENTATION_HORIZONTAL) + { + start = allocation->y + SEP_START * allocation->height; + end = allocation->y + SEP_END * allocation->height; + position = allocation->x + allocation->width / 2; - gtk_paint_vline (widget->style, widget->window, + gtk_paint_vline (widget->style, widget->window, GTK_STATE_NORMAL, &(event->area), widget, "separator", start, end, position); - } - else - { - start = allocation->x + SEP_START * allocation->width; - end = allocation->x + SEP_END * allocation->width; - position = allocation->y + allocation->height / 2; + } + else + { + start = allocation->x + SEP_START * allocation->width; + end = allocation->x + SEP_END * allocation->width; + position = allocation->y + allocation->height / 2; - gtk_paint_hline (widget->style, widget->window, + gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL, &(event->area), widget, "separator", start, end, position); + } + break; + case SEP_HANDLE: + gtk_paint_handle (widget->style, widget->window, + GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE, + &(event->area), widget, "handle", + allocation->x, allocation->y, allocation->width, allocation->height, + (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL); + break; } return TRUE; @@ -93,6 +109,9 @@ { GtkWidget *widget; + /* destroy previous widget */ + if (GTK_BIN (plugin)->child) + gtk_widget_destroy (GTK_BIN (plugin)->child); widget = gtk_drawing_area_new (); gtk_widget_show (widget); gtk_container_add (GTK_CONTAINER (plugin), widget); @@ -132,11 +151,7 @@ { char *file; XfceRc *rc; - int line, expand; - line = 1; - expand = 0; - if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL) { rc = xfce_rc_simple_open (file, TRUE); @@ -144,19 +159,13 @@ if (rc != NULL) { - line = xfce_rc_read_int_entry (rc, "draw-separator", 1); - - expand = xfce_rc_read_int_entry (rc, "expand", 0); - + separator_type = xfce_rc_read_int_entry (rc, "separator-type", 2); xfce_rc_close (rc); } } - if (line) + if (separator_type > 1) separator_add_widget (plugin); - - if (expand) - xfce_panel_plugin_set_expand (plugin, TRUE); } static void @@ -174,12 +183,7 @@ if (!rc) return; - xfce_rc_write_int_entry (rc, "draw-separator", - GTK_BIN (plugin)->child ? 1 : 0); - - xfce_rc_write_int_entry (rc, "expand", - xfce_panel_plugin_get_expand (plugin) ? 1 : 0); - + xfce_rc_write_int_entry (rc, "separator-type", separator_type); xfce_rc_close (rc); } @@ -220,12 +224,14 @@ * -------------------------------------------------------------------- */ static void -separator_toggled (GtkToggleButton *tb, XfcePanelPlugin *plugin) +empty_toggled (GtkToggleButton *tb, XfcePanelPlugin *plugin) { if (gtk_toggle_button_get_active (tb)) - separator_add_widget (plugin); - else - gtk_widget_destroy (GTK_BIN (plugin)->child); + { + separator_type = SEP_EMPTY; + if (GTK_BIN (plugin)->child) + gtk_widget_destroy (GTK_BIN (plugin)->child); + } } static void @@ -235,6 +241,26 @@ } static void +line_toggled (GtkToggleButton *tb, XfcePanelPlugin *plugin) +{ + if (gtk_toggle_button_get_active (tb)) + { + separator_type = SEP_LINE; + separator_add_widget (plugin); + } +} + +static void +handle_toggled (GtkToggleButton *tb, XfcePanelPlugin *plugin) +{ + if (gtk_toggle_button_get_active (tb)) + { + separator_type = SEP_HANDLE; + separator_add_widget (plugin); + } +} + +static void separator_dialog_response (GtkWidget *dlg, int reponse, XfcePanelPlugin *plugin) { @@ -276,24 +302,42 @@ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox, TRUE, TRUE, 0); - tb = gtk_check_button_new_with_mnemonic (_("_Draw Separator")); + tb = gtk_radio_button_new_with_mnemonic (NULL, _("_Empty")); gtk_widget_show (tb); gtk_box_pack_start (GTK_BOX (vbox), tb, FALSE, FALSE, 0); - if (GTK_BIN (plugin)->child != NULL) + if (separator_type == SEP_EMPTY) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), TRUE); - g_signal_connect (tb, "toggled", G_CALLBACK (separator_toggled), plugin); + g_signal_connect (tb, "toggled", G_CALLBACK (empty_toggled), plugin); - tb = gtk_check_button_new_with_mnemonic (_("_Expand")); + tb = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON(tb),_("_Expand")); gtk_widget_show (tb); gtk_box_pack_start (GTK_BOX (vbox), tb, FALSE, FALSE, 0); - if (xfce_panel_plugin_get_expand (plugin)) + if (separator_type == SEP_EXPAND) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), TRUE); g_signal_connect (tb, "toggled", G_CALLBACK (expand_toggled), plugin); + tb = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON(tb), _("_Line")); + gtk_widget_show (tb); + gtk_box_pack_start (GTK_BOX (vbox), tb, FALSE, FALSE, 0); + + if (separator_type == SEP_LINE) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), TRUE); + + g_signal_connect (tb, "toggled", G_CALLBACK (line_toggled), plugin); + + tb = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON(tb), _("_Handle")); + gtk_widget_show (tb); + gtk_box_pack_start (GTK_BOX (vbox), tb, FALSE, FALSE, 0); + + if (separator_type == SEP_HANDLE) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), TRUE); + + g_signal_connect (tb, "toggled", G_CALLBACK (handle_toggled), plugin); + gtk_widget_show (dlg); }