summaryrefslogtreecommitdiff
path: root/charpick
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2020-09-03 20:36:57 +0200
committerRobert Antoni Buj Gelonch <[email protected]>2020-10-27 08:07:54 +0100
commit3eefbc5c8946e5d98e2cab5ff7e22513967ac726 (patch)
tree755e98ecf7e3494baf8cd2c420762daa1c0dfaf7 /charpick
parentf61476bf3632cd9af624a1832476cadc89b64411 (diff)
downloadmate-applets-3eefbc5c8946e5d98e2cab5ff7e22513967ac726.tar.bz2
mate-applets-3eefbc5c8946e5d98e2cab5ff7e22513967ac726.tar.xz
charpick: improve code-style
- tab to spaces - fix indents - shorten lines
Diffstat (limited to 'charpick')
-rw-r--r--charpick/charpick.c1198
-rw-r--r--charpick/charpick.h58
-rw-r--r--charpick/properties.c972
3 files changed, 1133 insertions, 1095 deletions
diff --git a/charpick/charpick.c b/charpick/charpick.c
index 619d44c8..7c4170f5 100644
--- a/charpick/charpick.c
+++ b/charpick/charpick.c
@@ -87,99 +87,97 @@ static const gunichar ZA_code[] = {7699, 7741, 7755, 7793, 7698, 7740, 7754, 779
/* static const gchar *af_ZA_list = "áéíóúýêîôûèäëïöüÁÉÍÓÚÝÊÎÔÛÈÄËÏÖÜ"; */
static const gunichar af_ZA_code[] = {225, 233, 237, 243, 250, 253, 234, 238, 244, 251, 232, 228, 235, 239, 246, 252, 193, 201, 205, 211, 218, 221, 202, 206, 212, 219, 200, 196, 203, 207, 214, 220, 0};
-
static const gunichar * const chartable[] = {
- def_code,
- a_code,
- cap_a_code,
- c_code,
- e_code,
- cap_e_code,
- i_code,
- cap_i_code,
- n_code,
- o_code,
- cap_o_code,
- s_code,
- t_code,
- u_code,
- cap_u_code,
- y_code,
- dash_code,
- quote_code,
- currency_code,
- one_code,
- misc_code,
- ZA_code,
- af_ZA_code
+ def_code,
+ a_code,
+ cap_a_code,
+ c_code,
+ e_code,
+ cap_e_code,
+ i_code,
+ cap_i_code,
+ n_code,
+ o_code,
+ cap_o_code,
+ s_code,
+ t_code,
+ u_code,
+ cap_u_code,
+ y_code,
+ dash_code,
+ quote_code,
+ currency_code,
+ one_code,
+ misc_code,
+ ZA_code,
+ af_ZA_code
};
/* sets the picked character as the selection when it gets a request */
static void
-charpick_selection_handler(GtkWidget *widget,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- gpointer data)
+charpick_selection_handler (GtkWidget *widget,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ gpointer data)
{
- charpick_data *p_curr_data = data;
- gint num;
- gchar tmp[7];
- num = g_unichar_to_utf8 (p_curr_data->selected_unichar, tmp);
- tmp[num] = '\0';
-
- gtk_selection_data_set_text (selection_data, tmp, -1);
+ charpick_data *p_curr_data = data;
+ gint num;
+ gchar tmp[7];
+ num = g_unichar_to_utf8 (p_curr_data->selected_unichar, tmp);
+ tmp[num] = '\0';
+
+ gtk_selection_data_set_text (selection_data, tmp, -1);
- return;
+ return;
}
/* untoggles the active toggle_button when we lose the selection */
static gint
-selection_clear_cb (GtkWidget *widget, GdkEventSelection *event,
- gpointer data)
+selection_clear_cb (GtkWidget *widget,
+ GdkEventSelection *event,
+ gpointer data)
{
- charpick_data *curr_data = data;
-
- if (curr_data->last_toggle_button)
- gtk_toggle_button_set_active (curr_data->last_toggle_button, FALSE);
+ charpick_data *curr_data = data;
- curr_data->last_toggle_button = NULL;
- return TRUE;
-}
+ if (curr_data->last_toggle_button)
+ gtk_toggle_button_set_active (curr_data->last_toggle_button, FALSE);
+ curr_data->last_toggle_button = NULL;
+ return TRUE;
+}
static gint
-toggle_button_toggled_cb(GtkToggleButton *button, gpointer data)
+toggle_button_toggled_cb (GtkToggleButton *button,
+ gpointer data)
{
- charpick_data *curr_data = data;
- gint button_index;
- gboolean toggled;
-
- button_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "index"));
- toggled = gtk_toggle_button_get_active (button);
-
- if (toggled)
- {
- gunichar unichar;
- if (curr_data->last_toggle_button && (button != curr_data->last_toggle_button))
- gtk_toggle_button_set_active (curr_data->last_toggle_button,
- FALSE);
-
- curr_data->last_toggle_button = button;
- gtk_widget_grab_focus(curr_data->applet);
- unichar = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "unichar"));
- curr_data->selected_unichar = unichar;
- /* set this? widget as the selection owner */
- gtk_selection_owner_set (curr_data->applet,
- GDK_SELECTION_PRIMARY,
- GDK_CURRENT_TIME);
- gtk_selection_owner_set (curr_data->applet,
- GDK_SELECTION_CLIPBOARD,
- GDK_CURRENT_TIME);
- curr_data->last_index = button_index;
- }
-
- return TRUE;
+ charpick_data *curr_data = data;
+ gint button_index;
+ gboolean toggled;
+
+ button_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "index"));
+ toggled = gtk_toggle_button_get_active (button);
+
+ if (toggled)
+ {
+ gunichar unichar;
+ if (curr_data->last_toggle_button && (button != curr_data->last_toggle_button))
+ gtk_toggle_button_set_active (curr_data->last_toggle_button, FALSE);
+
+ curr_data->last_toggle_button = button;
+ gtk_widget_grab_focus (curr_data->applet);
+ unichar = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "unichar"));
+ curr_data->selected_unichar = unichar;
+ /* set this? widget as the selection owner */
+ gtk_selection_owner_set (curr_data->applet,
+ GDK_SELECTION_PRIMARY,
+ GDK_CURRENT_TIME);
+ gtk_selection_owner_set (curr_data->applet,
+ GDK_SELECTION_CLIPBOARD,
+ GDK_CURRENT_TIME);
+ curr_data->last_index = button_index;
+ }
+ return TRUE;
}
/* This is a hack around the fact that gtk+ doesn't
@@ -187,161 +185,168 @@ toggle_button_toggled_cb(GtkToggleButton *button, gpointer data)
*/
static gboolean
button_press_hack (GtkWidget *widget,
- GdkEventButton *event,
- GtkWidget *applet)
+ GdkEventButton *event,
+ GtkWidget *applet)
{
if (event->button == 3 || event->button == 2) {
- gtk_propagate_event (applet, (GdkEvent *) event);
+ gtk_propagate_event (applet, (GdkEvent *) event);
- return TRUE;
+ return TRUE;
}
return FALSE;
}
static gint
-key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
+key_press_event (GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer data)
{
#if 0
- charpick_data *p_curr_data = data;
- const gunichar *code = NULL;
- gchar inputchar = event->keyval;
-
- switch (inputchar)
- {
- case 'a' : code = a_code;
- break;
- case 'A' : code = cap_a_code;
- break;
- case 'c' :
- case 'C' : code = c_code;
- break;
- case 'e' : code = e_code;
- break;
- case 'E' : code = cap_e_code;
- break;
- case 'i' : code = i_code;
- break;
- case 'I' : code = cap_i_code;
- break;
- case 'n' :
- case 'N' : code = n_code;
- break;
- case 'o' : code = o_code;
- break;
- case 'O' : code = cap_o_code;
- break;
- case 's' : code = s_code;
- break;
- case 't' :
- case 'T' : code = t_code;
- break;
- case 'u' : code = u_code;
- break;
- case 'U' : code = cap_u_code;
- break;
- case 'y' :
- case 'Y' : code = y_code;
- break;
- case '-' : code = dash_code;
- break;
- case '\"' : code = quote_code;
- break;
- case '$' : code = currency_code;
- break;
- case '1' :
- case '2' :
- case '3' : code = one_code;
- break;
- case 'd' : code = NULL;
- break;
- default :
- return FALSE;
+ charpick_data *p_curr_data = data;
+ const gunichar *code = NULL;
+ gchar inputchar = event->keyval;
+
+ switch (inputchar)
+ {
+ case 'a' : code = a_code;
+ break;
+ case 'A' : code = cap_a_code;
+ break;
+ case 'c' :
+ case 'C' : code = c_code;
+ break;
+ case 'e' : code = e_code;
+ break;
+ case 'E' : code = cap_e_code;
+ break;
+ case 'i' : code = i_code;
+ break;
+ case 'I' : code = cap_i_code;
+ break;
+ case 'n' :
+ case 'N' : code = n_code;
+ break;
+ case 'o' : code = o_code;
+ break;
+ case 'O' : code = cap_o_code;
+ break;
+ case 's' : code = s_code;
+ break;
+ case 't' :
+ case 'T' : code = t_code;
+ break;
+ case 'u' : code = u_code;
+ break;
+ case 'U' : code = cap_u_code;
+ break;
+ case 'y' :
+ case 'Y' : code = y_code;
+ break;
+ case '-' : code = dash_code;
+ break;
+ case '\"' : code = quote_code;
+ break;
+ case '$' : code = currency_code;
+ break;
+ case '1' :
+ case '2' :
+ case '3' : code = one_code;
+ break;
+ case 'd' : code = NULL;
+ break;
+ default :
+ return FALSE;
}
- /* FIXME: what's wrong here ? */
- if (code)
- p_curr_data->charlist = g_ucs4_to_utf8 (code, -1, NULL, NULL, NULL);
- else
- p_curr_data->charlist = "hello";
- p_curr_data->last_index = NO_LAST_INDEX;
- p_curr_data->last_toggle_button = NULL;
- build_table(p_curr_data);
+ /* FIXME: what's wrong here ? */
+ if (code)
+ p_curr_data->charlist = g_ucs4_to_utf8 (code, -1, NULL, NULL, NULL);
+ else
+ p_curr_data->charlist = "hello";
+ p_curr_data->last_index = NO_LAST_INDEX;
+ p_curr_data->last_toggle_button = NULL;
+ build_table (p_curr_data);
#endif
return FALSE;
}
static void
-menuitem_activated (GtkMenuItem *menuitem, charpick_data *curr_data)
+menuitem_activated (GtkMenuItem *menuitem,
+ charpick_data *curr_data)
{
- gchar *string;
-
- string = g_object_get_data (G_OBJECT (menuitem), "string");
- if (g_ascii_strcasecmp (curr_data->charlist, string) == 0)
- return;
-
- curr_data->charlist = string;
- build_table (curr_data);
- if (g_settings_is_writable (curr_data->settings, "current-list"))
- g_settings_set_string (curr_data->settings, "current-list", curr_data->charlist);
+ gchar *string;
+
+ string = g_object_get_data (G_OBJECT (menuitem), "string");
+ if (g_ascii_strcasecmp (curr_data->charlist, string) == 0)
+ return;
+
+ curr_data->charlist = string;
+ build_table (curr_data);
+ if (g_settings_is_writable (curr_data->settings, "current-list"))
+ g_settings_set_string (curr_data->settings,
+ "current-list",
+ curr_data->charlist);
}
void
populate_menu (charpick_data *curr_data)
{
- GList *list = curr_data->chartable;
- GSList *group = NULL;
- GtkMenu *menu;
- GtkWidget *menuitem;
-
- if (curr_data->menu)
- gtk_widget_destroy (curr_data->menu);
-
- curr_data->menu = gtk_menu_new ();
- menu = GTK_MENU (curr_data->menu);
-
- while (list) {
- gchar *string = list->data;
- menuitem = gtk_radio_menu_item_new_with_label (group, string);
- group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem));
- gtk_widget_show (menuitem);
- g_object_set_data (G_OBJECT (menuitem), "string", string);
- g_signal_connect (G_OBJECT (menuitem), "activate",
- G_CALLBACK (menuitem_activated), curr_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- if (g_ascii_strcasecmp (curr_data->charlist, string) == 0)
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), TRUE);
- list = g_list_next (list);
- }
- build_table(curr_data);
-
- /*Set up custom theme and transparency support*/
- GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu));
- /* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
- GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
- GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
- gtk_widget_set_visual(GTK_WIDGET(toplevel), visual);
- /* Set menu and it's toplevel window to follow panel theme */
- GtkStyleContext *context;
- context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
- gtk_style_context_add_class(context,"gnome-panel-menu-bar");
- gtk_style_context_add_class(context,"mate-panel-menu-bar");
+ GList *list = curr_data->chartable;
+ GSList *group = NULL;
+ GtkMenu *menu;
+ GtkWidget *menuitem;
+
+ if (curr_data->menu)
+ gtk_widget_destroy (curr_data->menu);
+
+ curr_data->menu = gtk_menu_new ();
+ menu = GTK_MENU (curr_data->menu);
+
+ while (list) {
+ gchar *string = list->data;
+ menuitem = gtk_radio_menu_item_new_with_label (group, string);
+ group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem));
+ gtk_widget_show (menuitem);
+ g_object_set_data (G_OBJECT (menuitem), "string", string);
+ g_signal_connect (G_OBJECT (menuitem), "activate",
+ G_CALLBACK (menuitem_activated),
+ curr_data);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ if (g_ascii_strcasecmp (curr_data->charlist, string) == 0)
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), TRUE);
+ list = g_list_next (list);
+ }
+ build_table (curr_data);
+
+ /*Set up custom theme and transparency support*/
+ GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu));
+ /* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
+ GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (toplevel));
+ GdkVisual *visual = gdk_screen_get_rgba_visual (screen);
+ gtk_widget_set_visual (GTK_WIDGET (toplevel), visual);
+ /* Set menu and it's toplevel window to follow panel theme */
+ GtkStyleContext *context;
+ context = gtk_widget_get_style_context (GTK_WIDGET (toplevel));
+ gtk_style_context_add_class (context, "gnome-panel-menu-bar");
+ gtk_style_context_add_class (context, "mate-panel-menu-bar");
}
static void
-chooser_button_clicked (GtkButton *button, charpick_data *curr_data)
+chooser_button_clicked (GtkButton *button,
+ charpick_data *curr_data)
{
- if (gtk_widget_get_visible (curr_data->menu))
- gtk_menu_popdown (GTK_MENU (curr_data->menu));
- else {
- gtk_menu_set_screen (GTK_MENU (curr_data->menu),
- gtk_widget_get_screen (GTK_WIDGET (curr_data->applet)));
-
- gtk_menu_popup_at_widget (GTK_MENU (curr_data->menu),
- GTK_WIDGET (button),
- GDK_GRAVITY_SOUTH_WEST,
- GDK_GRAVITY_NORTH_WEST,
- NULL);
- }
+ if (gtk_widget_get_visible (curr_data->menu))
+ gtk_menu_popdown (GTK_MENU (curr_data->menu));
+ else {
+ gtk_menu_set_screen (GTK_MENU (curr_data->menu),
+ gtk_widget_get_screen (GTK_WIDGET (curr_data->applet)));
+
+ gtk_menu_popup_at_widget (GTK_MENU (curr_data->menu),
+ GTK_WIDGET (button),
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ NULL);
+ }
}
/* Force the button not to have any focus padding and let the focus
@@ -350,478 +355,503 @@ chooser_button_clicked (GtkButton *button, charpick_data *curr_data)
static inline void force_no_button_padding (GtkWidget *widget)
{
- GtkCssProvider *provider;
+ GtkCssProvider *provider;
+
+ provider = gtk_css_provider_new ();
- provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider,
+ "#charpick-applet-button {\n"
+ "border-width: 0px;\n"
+ "padding: 0px;\n"
+ "margin: 0px;\n"
+ "}",
+ -1,
+ NULL);
- gtk_css_provider_load_from_data (provider,
- "#charpick-applet-button {\n"
- "border-width: 0px;\n"
- "padding: 0px;\n"
- "margin: 0px;\n"
- "}",
- -1,
- NULL);
- gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (provider);
+ g_object_unref (provider);
- gtk_widget_set_name (widget, "charpick-applet-button");
+ gtk_widget_set_name (widget, "charpick-applet-button");
}
/* creates table of buttons, sets up their callbacks, and packs the table in
the event box */
void
-build_table(charpick_data *p_curr_data)
+build_table (charpick_data *p_curr_data)
{
- GtkWidget *box, *button_box, **row_box;
- GtkWidget *button, *arrow;
- gint i = 0, len = g_utf8_strlen (p_curr_data->charlist, -1);
- GtkWidget **toggle_button;
- gchar *charlist;
- gint max_width=1, max_height=1;
- gint size_ratio;
-
- toggle_button = g_new (GtkWidget *, len);
-
- if (p_curr_data->box)
- gtk_widget_destroy(p_curr_data->box);
-
- if (p_curr_data->panel_vertical)
- box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- else
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_widget_show (box);
- p_curr_data->box = box;
-
- button = gtk_button_new ();
- if (g_list_length (p_curr_data->chartable) != 1)
- {
- gtk_widget_set_tooltip_text (button, _("Available palettes"));
-
- switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (p_curr_data->applet))) {
- case MATE_PANEL_APPLET_ORIENT_DOWN:
- arrow = gtk_image_new_from_icon_name ("pan-down-symbolic", GTK_ICON_SIZE_MENU);
- break;
- case MATE_PANEL_APPLET_ORIENT_UP:
- arrow = gtk_image_new_from_icon_name ("pan-up-symbolic", GTK_ICON_SIZE_MENU);
- break;
- case MATE_PANEL_APPLET_ORIENT_LEFT:
- arrow = gtk_image_new_from_icon_name ("pan-start-symbolic", GTK_ICON_SIZE_MENU);
- break;
- case MATE_PANEL_APPLET_ORIENT_RIGHT:
- arrow = gtk_image_new_from_icon_name ("pan-end-symbolic", GTK_ICON_SIZE_MENU);
- break;
- default:
- g_assert_not_reached ();
+ GtkWidget *box, *button_box, **row_box;
+ GtkWidget *button, *arrow;
+ gint i = 0, len = g_utf8_strlen (p_curr_data->charlist, -1);
+ GtkWidget **toggle_button;
+ gchar *charlist;
+ gint max_width=1, max_height=1;
+ gint size_ratio;
+
+ toggle_button = g_new (GtkWidget *, len);
+
+ if (p_curr_data->box)
+ gtk_widget_destroy (p_curr_data->box);
+
+ if (p_curr_data->panel_vertical)
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ else
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+ gtk_widget_show (box);
+ p_curr_data->box = box;
+
+ button = gtk_button_new ();
+ if (g_list_length (p_curr_data->chartable) != 1)
+ {
+ gtk_widget_set_tooltip_text (button, _("Available palettes"));
+
+ switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (p_curr_data->applet))) {
+ case MATE_PANEL_APPLET_ORIENT_DOWN:
+ arrow = gtk_image_new_from_icon_name ("pan-down-symbolic",
+ GTK_ICON_SIZE_MENU);
+ break;
+ case MATE_PANEL_APPLET_ORIENT_UP:
+ arrow = gtk_image_new_from_icon_name ("pan-up-symbolic",
+ GTK_ICON_SIZE_MENU);
+ break;
+ case MATE_PANEL_APPLET_ORIENT_LEFT:
+ arrow = gtk_image_new_from_icon_name ("pan-start-symbolic",
+ GTK_ICON_SIZE_MENU);
+ break;
+ case MATE_PANEL_APPLET_ORIENT_RIGHT:
+ arrow = gtk_image_new_from_icon_name ("pan-end-symbolic",
+ GTK_ICON_SIZE_MENU);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ gtk_container_add (GTK_CONTAINER (button), arrow);
+
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+
+ /* FIXME : evil hack (see force_no_button_padding) */
+ force_no_button_padding (button);
+
+ gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (chooser_button_clicked),
+ p_curr_data);
+
+ g_signal_connect (G_OBJECT (button), "button_press_event",
+ G_CALLBACK (button_press_hack),
+ p_curr_data->applet);
}
- gtk_container_add (GTK_CONTAINER (button), arrow);
- gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
-
- /* FIXME : evil hack (see force_no_button_padding) */
- force_no_button_padding (button);
-
- gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (chooser_button_clicked),
- p_curr_data);
- g_signal_connect (G_OBJECT (button), "button_press_event",
- G_CALLBACK (button_press_hack),
- p_curr_data->applet);
-
- }
-
- charlist = g_strdup (p_curr_data->charlist);
- for (i = 0; i < len; i++) {
- gchar label[7];
- GtkRequisition req;
- gchar *atk_desc;
- gchar *name;
-
- g_utf8_strncpy (label, charlist, 1);
- charlist = g_utf8_next_char (charlist);
+
+ charlist = g_strdup (p_curr_data->charlist);
+ for (i = 0; i < len; i++) {
+ gchar label[7];
+ GtkRequisition req;
+ gchar *atk_desc;
+ gchar *name;
+ g_utf8_strncpy (label, charlist, 1);
+ charlist = g_utf8_next_char (charlist);
#ifdef HAVE_GUCHARMAP
- /* TRANSLATOR: This sentance reads something like 'Insert "PILCROW SIGN"'
- * hopefully, the name of the unicode character has already
- * been translated.
- */
- name = g_strdup_printf (_("Insert \"%s\""),
- gucharmap_get_unicode_name (g_utf8_get_char (label)));
+ /* TRANSLATOR: This sentance reads something like 'Insert "PILCROW SIGN"'
+ * hopefully, the name of the unicode character has already
+ * been translated.
+ */
+ name = g_strdup_printf (_("Insert \"%s\""),
+ gucharmap_get_unicode_name (g_utf8_get_char (label)));
#else
- name = g_strdup (_("Insert special character"));
+ name = g_strdup (_("Insert special character"));
#endif
- toggle_button[i] = gtk_toggle_button_new_with_label (label);
- atk_desc = g_strdup_printf (_("insert special character %s"), label);
- set_atk_name_description (toggle_button[i], NULL, atk_desc);
- g_free (atk_desc);
- gtk_widget_show (toggle_button[i]);
- gtk_button_set_relief(GTK_BUTTON(toggle_button[i]), GTK_RELIEF_NONE);
-
- /* FIXME : evil hack (see force_no_button_padding) */
- force_no_button_padding (toggle_button[i]);
-
- gtk_widget_set_tooltip_text (toggle_button[i], name);
- g_free (name);
-
- gtk_widget_get_preferred_size (toggle_button[i], NULL, &req);
-
- max_width = MAX (max_width, req.width);
- max_height = MAX (max_height, req.height-2);
-
- g_object_set_data (G_OBJECT (toggle_button[i]), "unichar",
- GINT_TO_POINTER(g_utf8_get_char (label)));
- g_signal_connect (G_OBJECT (toggle_button[i]), "toggled",
- G_CALLBACK (toggle_button_toggled_cb),
- p_curr_data);
- g_signal_connect (G_OBJECT (toggle_button[i]), "button_press_event",
- G_CALLBACK (button_press_hack), p_curr_data->applet);
- }
-
- if (p_curr_data->panel_vertical) {
- size_ratio = p_curr_data->panel_size / max_width;
- button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- } else {
- size_ratio = p_curr_data->panel_size / max_height;
- button_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- }
-
- gtk_box_set_homogeneous (GTK_BOX (button_box), TRUE);
- gtk_box_pack_start (GTK_BOX (box), button_box, TRUE, TRUE, 0);
-
- size_ratio = MAX (size_ratio, 1);
- row_box = g_new0 (GtkWidget *, size_ratio);
- for (i=0; i < size_ratio; i++) {
- if (!p_curr_data->panel_vertical) row_box[i] = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- else row_box[i] = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_set_homogeneous (GTK_BOX (row_box[i]), TRUE);
- gtk_box_pack_start (GTK_BOX (button_box), row_box[i], TRUE, TRUE, 0);
- }
-
- for (i = 0; i <len; i++) {
- int delta = len/size_ratio;
- int index;
-
- if (delta > 0)
- index = i / delta;
- else
- index = i;
+ toggle_button[i] = gtk_toggle_button_new_with_label (label);
+ atk_desc = g_strdup_printf (_("insert special character %s"), label);
- index = CLAMP (index, 0, size_ratio-1);
- gtk_box_pack_start (GTK_BOX (row_box[index]), toggle_button[i], TRUE, TRUE, 0);
- }
+ set_atk_name_description (toggle_button[i], NULL, atk_desc);
+ g_free (atk_desc);
+ gtk_widget_show (toggle_button[i]);
+ gtk_button_set_relief (GTK_BUTTON (toggle_button[i]), GTK_RELIEF_NONE);
- g_free (toggle_button);
- g_free (row_box);
+ /* FIXME : evil hack (see force_no_button_padding) */
+ force_no_button_padding (toggle_button[i]);
- gtk_container_add (GTK_CONTAINER(p_curr_data->applet), box);
- gtk_widget_show_all (p_curr_data->box);
+ gtk_widget_set_tooltip_text (toggle_button[i], name);
+ g_free (name);
- p_curr_data->last_index = NO_LAST_INDEX;
- p_curr_data->last_toggle_button = NULL;
-
+ gtk_widget_get_preferred_size (toggle_button[i], NULL, &req);
+
+ max_width = MAX (max_width, req.width);
+ max_height = MAX (max_height, req.height-2);
+
+ g_object_set_data (G_OBJECT (toggle_button[i]), "unichar",
+ GINT_TO_POINTER (g_utf8_get_char (label)));
+
+ g_signal_connect (G_OBJECT (toggle_button[i]), "toggled",
+ G_CALLBACK (toggle_button_toggled_cb),
+ p_curr_data);
+
+ g_signal_connect (G_OBJECT (toggle_button[i]), "button_press_event",
+ G_CALLBACK (button_press_hack),
+ p_curr_data->applet);
+ }
+
+ if (p_curr_data->panel_vertical) {
+ size_ratio = p_curr_data->panel_size / max_width;
+ button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ } else {
+ size_ratio = p_curr_data->panel_size / max_height;
+ button_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ }
+
+ gtk_box_set_homogeneous (GTK_BOX (button_box), TRUE);
+ gtk_box_pack_start (GTK_BOX (box), button_box, TRUE, TRUE, 0);
+
+ size_ratio = MAX (size_ratio, 1);
+ row_box = g_new0 (GtkWidget *, size_ratio);
+ for (i=0; i < size_ratio; i++) {
+ if (!p_curr_data->panel_vertical)
+ row_box[i] = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ else
+ row_box[i] = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+
+ gtk_box_set_homogeneous (GTK_BOX (row_box[i]), TRUE);
+ gtk_box_pack_start (GTK_BOX (button_box), row_box[i], TRUE, TRUE, 0);
+ }
+
+ for (i = 0; i <len; i++) {
+ int delta = len/size_ratio;
+ int index;
+
+ if (delta > 0)
+ index = i / delta;
+ else
+ index = i;
+
+ index = CLAMP (index, 0, size_ratio-1);
+ gtk_box_pack_start (GTK_BOX (row_box[index]),
+ toggle_button[i],
+ TRUE, TRUE, 0);
+ }
+
+ g_free (toggle_button);
+ g_free (row_box);
+
+ gtk_container_add (GTK_CONTAINER (p_curr_data->applet), box);
+ gtk_widget_show_all (p_curr_data->box);
+
+ p_curr_data->last_index = NO_LAST_INDEX;
+ p_curr_data->last_toggle_button = NULL;
}
-static void applet_size_allocate(MatePanelApplet *applet, GtkAllocation *allocation, gpointer data)
+static void
+applet_size_allocate (MatePanelApplet *applet,
+ GtkAllocation *allocation,
+ gpointer data)
{
- charpick_data *curr_data = data;
- if (curr_data->panel_vertical) {
- if (curr_data->panel_size == allocation->width)
- return;
- curr_data->panel_size = allocation->width;
- } else {
- if (curr_data->panel_size == allocation->height)
- return;
- curr_data->panel_size = allocation->height;
- }
-
- build_table (curr_data);
- return;
+ charpick_data *curr_data = data;
+ if (curr_data->panel_vertical) {
+ if (curr_data->panel_size == allocation->width)
+ return;
+ curr_data->panel_size = allocation->width;
+ } else {
+ if (curr_data->panel_size == allocation->height)
+ return;
+ curr_data->panel_size = allocation->height;
+ }
+
+ build_table (curr_data);
+ return;
}
-static void applet_change_orient(MatePanelApplet *applet, MatePanelAppletOrient o, gpointer data)
+static void
+applet_change_orient (MatePanelApplet *applet,
+ MatePanelAppletOrient o,
+ gpointer data)
{
- charpick_data *curr_data = data;
- if (o == MATE_PANEL_APPLET_ORIENT_UP ||
- o == MATE_PANEL_APPLET_ORIENT_DOWN)
- curr_data->panel_vertical = FALSE;
- else
- curr_data->panel_vertical = TRUE;
- build_table (curr_data);
- return;
+ charpick_data *curr_data = data;
+ if (o == MATE_PANEL_APPLET_ORIENT_UP ||
+ o == MATE_PANEL_APPLET_ORIENT_DOWN)
+ curr_data->panel_vertical = FALSE;
+ else
+ curr_data->panel_vertical = TRUE;
+
+ build_table (curr_data);
+ return;
}
-
static void
about (GtkAction *action,
charpick_data *curr_data)
{
- static const char * const authors[] = {
- "Alexandre Muñiz <[email protected]>",
- "Kevin Vandersloot",
- NULL
- };
-
- static const gchar* documenters[] = {
- "Dan Mueth <[email protected]>",
- N_("Sun GNOME Documentation Team <[email protected]>"),
- N_("MATE Documentation Team"),
- NULL
- };
+ static const char * const authors[] = {
+ "Alexandre Muñiz <[email protected]>",
+ "Kevin Vandersloot",
+ NULL
+ };
+
+ static const gchar* documenters[] = {
+ "Dan Mueth <[email protected]>",
+ N_("Sun GNOME Documentation Team <[email protected]>"),
+ N_("MATE Documentation Team"),
+ NULL
+ };
#ifdef ENABLE_NLS
- const char **p;
- for (p = documenters; *p; ++p)
- *p = _(*p);
+ const char **p;
+ for (p = documenters; *p; ++p)
+ *p = _(*p);
#endif
- gtk_show_about_dialog (NULL,
- "title", _("About Character Palette"),
- "version", VERSION,
- "copyright", _("Copyright \xc2\xa9 1998, 2004-2005 GNOME Applets Maintainers and others\n"
- "Copyright \xc2\xa9 2012-2020 MATE developers"),
- "comments", _("MATE Panel applet for selecting strange "
- "characters that are not on the keyboard. "
- "Released under GNU General Public Licence."),
- "authors", authors,
- "documenters", documenters,
- "translator-credits", _("translator-credits"),
- "logo-icon-name", "accessories-character-map",
- NULL);
+ gtk_show_about_dialog (NULL,
+ "title", _("About Character Palette"),
+ "version", VERSION,
+ "copyright", _("Copyright \xc2\xa9 1998, 2004-2005 GNOME Applets Maintainers and others\n"
+ "Copyright \xc2\xa9 2012-2020 MATE developers"),
+ "comments", _("MATE Panel applet for selecting strange "
+ "characters that are not on the keyboard. "
+ "Released under GNU General Public Licence."),
+ "authors", authors,
+ "documenters", documenters,
+ "translator-credits", _("translator-credits"),
+ "logo-icon-name", "accessories-character-map",
+ NULL);
}
-
static void
help_cb (GtkAction *action,
- charpick_data *curr_data)
+ charpick_data *curr_data)
{
- GError *error = NULL;
-
- gtk_show_uri_on_window (NULL,
- "help:mate-char-palette",
- gtk_get_current_event_time (),
- &error);
-
- if (error) { /* FIXME: the user needs to see this */
- g_warning ("help error: %s\n", error->message);
- g_error_free (error);
- error = NULL;
- }
+ GError *error = NULL;
+
+ gtk_show_uri_on_window (NULL,
+ "help:mate-char-palette",
+ gtk_get_current_event_time (),
+ &error);
+
+ if (error) { /* FIXME: the user needs to see this */
+ g_warning ("help error: %s\n", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
}
static void
-applet_destroy (GtkWidget *widget, gpointer data)
+applet_destroy (GtkWidget *widget,
+ gpointer data)
{
- charpick_data *curr_data = data;
-
- g_return_if_fail (curr_data);
-
- if (curr_data->about_dialog)
- gtk_widget_destroy (curr_data->about_dialog);
- if (curr_data->propwindow)
- gtk_widget_destroy (curr_data->propwindow);
- if (curr_data->box)
- gtk_widget_destroy (curr_data->box);
- if (curr_data->menu)
- gtk_widget_destroy (curr_data->menu);
- g_free (curr_data);
-
+ charpick_data *curr_data = data;
+
+ g_return_if_fail (curr_data);
+
+ if (curr_data->about_dialog)
+ gtk_widget_destroy (curr_data->about_dialog);
+ if (curr_data->propwindow)
+ gtk_widget_destroy (curr_data->propwindow);
+ if (curr_data->box)
+ gtk_widget_destroy (curr_data->box);
+ if (curr_data->menu)
+ gtk_widget_destroy (curr_data->menu);
+ g_free (curr_data);
}
void
save_chartable (charpick_data *curr_data)
{
- mate_panel_applet_settings_set_glist (curr_data->settings,
- "chartable", curr_data->chartable);
+ mate_panel_applet_settings_set_glist (curr_data->settings,
+ "chartable",
+ curr_data->chartable);
}
static void
get_chartable (charpick_data *curr_data)
{
- gint i, n;
- GList *value = NULL;
-
- value = mate_panel_applet_settings_get_glist (curr_data->settings, "chartable");
- if (value) {
- curr_data->chartable = value;
- }
- else {
- n = G_N_ELEMENTS (chartable);
- for (i=0; i<n; i++) {
- gchar *string;
-
- string = g_ucs4_to_utf8 (chartable[i], -1, NULL, NULL, NULL);
- curr_data->chartable = g_list_append (curr_data->chartable, string);
- }
- if ( ! g_settings_is_writable (curr_data->settings, "chartable"))
- save_chartable (curr_data);
- }
+ gint i, n;
+ GList *value = NULL;
+
+ value = mate_panel_applet_settings_get_glist (curr_data->settings, "chartable");
+ if (value) {
+ curr_data->chartable = value;
+ }
+ else {
+ n = G_N_ELEMENTS (chartable);
+ for (i=0; i<n; i++) {
+ gchar *string;
+
+ string = g_ucs4_to_utf8 (chartable[i], -1, NULL, NULL, NULL);
+ curr_data->chartable = g_list_append (curr_data->chartable, string);
+ }
+ if (! g_settings_is_writable (curr_data->settings, "chartable"))
+ save_chartable (curr_data);
+ }
}
static const GtkActionEntry charpick_applet_menu_actions [] = {
- { "Preferences", "document-properties", N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (show_preferences_dialog) },
- { "Help", "help-browser", N_("_Help"),
- NULL, NULL,
- G_CALLBACK (help_cb) },
- { "About", "help-about", N_("_About"),
- NULL, NULL,
- G_CALLBACK (about) }
+ { "Preferences", "document-properties", N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (show_preferences_dialog) },
+ { "Help", "help-browser", N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (help_cb) },
+ { "About", "help-about", N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (about) }
};
void
-set_atk_name_description (GtkWidget *widget, const gchar *name,
+set_atk_name_description (GtkWidget *widget,
+ const gchar *name,
const gchar *description)
{
- AtkObject *aobj;
- aobj = gtk_widget_get_accessible (widget);
- /* return if gail is not loaded */
- if (GTK_IS_ACCESSIBLE (aobj) == FALSE)
- return;
- if (name)
- atk_object_set_name (aobj, name);
- if (description)
- atk_object_set_description (aobj, description);
+ AtkObject *aobj;
+ aobj = gtk_widget_get_accessible (widget);
+ /* return if gail is not loaded */
+ if (GTK_IS_ACCESSIBLE (aobj) == FALSE)
+ return;
+ if (name)
+ atk_object_set_name (aobj, name);
+ if (description)
+ atk_object_set_description (aobj, description);
}
static void
make_applet_accessible (GtkWidget *applet)
{
- set_atk_name_description (applet, _("Character Palette"), _("Insert characters"));
+ set_atk_name_description (applet, _("Character Palette"), _("Insert characters"));
}
static gboolean
charpicker_applet_fill (MatePanelApplet *applet)
{
- MatePanelAppletOrient orientation;
- charpick_data *curr_data;
- GdkAtom utf8_atom;
- GList *list;
- gchar *string;
- GtkActionGroup *action_group;
-
- g_set_application_name (_("Character Palette"));
-
- gtk_window_set_default_icon_name ("accessories-character-map");
+ MatePanelAppletOrient orientation;
+ charpick_data *curr_data;
+ GdkAtom utf8_atom;
+ GList *list;
+ gchar *string;
+ GtkActionGroup *action_group;
- mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
+ g_set_application_name (_("Character Palette"));
- mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
-
- curr_data = g_new0 (charpick_data, 1);
- curr_data->last_index = NO_LAST_INDEX;
- curr_data->applet = GTK_WIDGET (applet);
- curr_data->about_dialog = NULL;
- curr_data->add_edit_dialog = NULL;
- curr_data->settings = mate_panel_applet_settings_new (applet, "org.mate.panel.applet.charpick");
-
- get_chartable (curr_data);
-
- string = g_settings_get_string (curr_data->settings, "current-list");
- if (string) {
- list = curr_data->chartable;
- while (list) {
- if (g_ascii_strcasecmp (list->data, string) == 0)
- curr_data->charlist = list->data;
- list = g_list_next (list);
- }
- /* FIXME: yeah leak, but this code is full of leaks and evil
- point shuffling. This should really be rewritten
- -George */
- if (curr_data->charlist == NULL)
- curr_data->charlist = string;
- else
- g_free (string);
- } else {
- curr_data->charlist = curr_data->chartable->data;
- }
+ gtk_window_set_default_icon_name ("accessories-character-map");
+
+ mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
+
+ mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
+
+ curr_data = g_new0 (charpick_data, 1);
+ curr_data->last_index = NO_LAST_INDEX;
+ curr_data->applet = GTK_WIDGET (applet);
+ curr_data->about_dialog = NULL;
+ curr_data->add_edit_dialog = NULL;
+ curr_data->settings = mate_panel_applet_settings_new (applet,
+ "org.mate.panel.applet.charpick");
- curr_data->panel_size = mate_panel_applet_get_size (applet);
+ get_chartable (curr_data);
+
+ string = g_settings_get_string (curr_data->settings, "current-list");
+ if (string) {
+ list = curr_data->chartable;
+ while (list) {
+ if (g_ascii_strcasecmp (list->data, string) == 0)
+ curr_data->charlist = list->data;
+ list = g_list_next (list);
+ }
+ /* FIXME: yeah leak, but this code is full of leaks and evil
+ point shuffling. This should really be rewritten
+ -George */
+ if (curr_data->charlist == NULL)
+ curr_data->charlist = string;
+ else
+ g_free (string);
+ }
+ else {
+ curr_data->charlist = curr_data->chartable->data;
+ }
+
+ curr_data->panel_size = mate_panel_applet_get_size (applet);
- orientation = mate_panel_applet_get_orient (applet);
- curr_data->panel_vertical = (orientation == MATE_PANEL_APPLET_ORIENT_LEFT)
- || (orientation == MATE_PANEL_APPLET_ORIENT_RIGHT);
- build_table (curr_data);
-
- g_signal_connect (G_OBJECT (curr_data->applet), "key_press_event",
- G_CALLBACK (key_press_event), curr_data);
-
- utf8_atom = gdk_atom_intern ("UTF8_STRING", FALSE);
- gtk_selection_add_target (curr_data->applet,
- GDK_SELECTION_PRIMARY,
- utf8_atom,
- 0);
- gtk_selection_add_target (curr_data->applet,
- GDK_SELECTION_CLIPBOARD,
- utf8_atom,
- 0);
- g_signal_connect (G_OBJECT (curr_data->applet), "selection_get",
- G_CALLBACK (charpick_selection_handler),
- curr_data);
- g_signal_connect (G_OBJECT (curr_data->applet), "selection_clear_event",
- G_CALLBACK (selection_clear_cb),
- curr_data);
-
- make_applet_accessible (GTK_WIDGET (applet));
+ orientation = mate_panel_applet_get_orient (applet);
+ curr_data->panel_vertical = (orientation == MATE_PANEL_APPLET_ORIENT_LEFT)
+ || (orientation == MATE_PANEL_APPLET_ORIENT_RIGHT);
+ build_table (curr_data);
- /* session save signal */
- g_signal_connect (G_OBJECT (applet), "change_orient",
- G_CALLBACK (applet_change_orient), curr_data);
+ g_signal_connect (G_OBJECT (curr_data->applet), "key_press_event",
+ G_CALLBACK (key_press_event), curr_data);
- g_signal_connect (G_OBJECT (applet), "size_allocate",
- G_CALLBACK (applet_size_allocate), curr_data);
-
- g_signal_connect (G_OBJECT (applet), "destroy",
- G_CALLBACK (applet_destroy), curr_data);
-
- gtk_widget_show_all (GTK_WIDGET (applet));
+ utf8_atom = gdk_atom_intern ("UTF8_STRING", FALSE);
+
+ gtk_selection_add_target (curr_data->applet,
+ GDK_SELECTION_PRIMARY,
+ utf8_atom, 0);
- action_group = gtk_action_group_new ("Charpicker Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- charpick_applet_menu_actions,
- G_N_ELEMENTS (charpick_applet_menu_actions),
- curr_data);
+ gtk_selection_add_target (curr_data->applet,
+ GDK_SELECTION_CLIPBOARD,
+ utf8_atom, 0);
- mate_panel_applet_setup_menu_from_resource (MATE_PANEL_APPLET (applet),
- CHARPICK_RESOURCE_PATH "charpick-applet-menu.xml",
- action_group);
+ g_signal_connect (G_OBJECT (curr_data->applet), "selection_get",
+ G_CALLBACK (charpick_selection_handler),
+ curr_data);
- if (mate_panel_applet_get_locked_down (MATE_PANEL_APPLET (applet))) {
- GtkAction *action;
+ g_signal_connect (G_OBJECT (curr_data->applet), "selection_clear_event",
+ G_CALLBACK (selection_clear_cb),
+ curr_data);
- action = gtk_action_group_get_action (action_group, "Preferences");
- gtk_action_set_visible (action, FALSE);
- }
- g_object_unref (action_group);
+ make_applet_accessible (GTK_WIDGET (applet));
- register_stock_for_edit ();
- populate_menu (curr_data);
+ /* session save signal */
+ g_signal_connect (G_OBJECT (applet), "change_orient",
+ G_CALLBACK (applet_change_orient), curr_data);
- return TRUE;
+ g_signal_connect (G_OBJECT (applet), "size_allocate",
+ G_CALLBACK (applet_size_allocate), curr_data);
+
+ g_signal_connect (G_OBJECT (applet), "destroy",
+ G_CALLBACK (applet_destroy), curr_data);
+
+ gtk_widget_show_all (GTK_WIDGET (applet));
+
+ action_group = gtk_action_group_new ("Charpicker Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ charpick_applet_menu_actions,
+ G_N_ELEMENTS (charpick_applet_menu_actions),
+ curr_data);
+
+ mate_panel_applet_setup_menu_from_resource (MATE_PANEL_APPLET (applet),
+ CHARPICK_RESOURCE_PATH "charpick-applet-menu.xml",
+ action_group);
+
+ if (mate_panel_applet_get_locked_down (MATE_PANEL_APPLET (applet))) {
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (action_group, "Preferences");
+ gtk_action_set_visible (action, FALSE);
+ }
+ g_object_unref (action_group);
+
+ register_stock_for_edit ();
+ populate_menu (curr_data);
+
+ return TRUE;
}
static gboolean
charpicker_applet_factory (MatePanelApplet *applet,
- const gchar *iid,
- gpointer data)
+ const gchar *iid,
+ gpointer data)
{
- gboolean retval = FALSE;
-
- if (!strcmp (iid, "CharpickerApplet"))
- retval = charpicker_applet_fill (applet);
-
- return retval;
+ gboolean retval = FALSE;
+
+ if (!strcmp (iid, "CharpickerApplet"))
+ retval = charpicker_applet_fill (applet);
+
+ return retval;
}
MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("CharpickerAppletFactory",
- PANEL_TYPE_APPLET,
- "char-palette",
- charpicker_applet_factory,
- NULL)
+ PANEL_TYPE_APPLET,
+ "char-palette",
+ charpicker_applet_factory,
+ NULL)
diff --git a/charpick/charpick.h b/charpick/charpick.h
index 57e44b27..7a70ef5b 100644
--- a/charpick/charpick.h
+++ b/charpick/charpick.h
@@ -15,26 +15,25 @@
typedef struct _charpick_data charpick_data;
/* this type has basically all data for this program */
struct _charpick_data {
- GList *chartable;
- gchar * charlist;
- gunichar selected_unichar;
- gint last_index;
- GtkWidget *box;
- GtkWidget *frame;
- GtkWidget *applet;
- GtkToggleButton *last_toggle_button;
- gint panel_size;
- gboolean panel_vertical;
- GtkWidget *propwindow;
- GtkWidget *about_dialog;
- GtkWidget *pref_tree;
- GtkWidget *menu;
- GtkWidget *add_edit_dialog;
- GtkWidget *add_edit_entry;
- GSettings *settings;
+ GList *chartable;
+ gchar *charlist;
+ gunichar selected_unichar;
+ gint last_index;
+ GtkWidget *box;
+ GtkWidget *frame;
+ GtkWidget *applet;
+ GtkToggleButton *last_toggle_button;
+ gint panel_size;
+ gboolean panel_vertical;
+ GtkWidget *propwindow;
+ GtkWidget *about_dialog;
+ GtkWidget *pref_tree;
+ GtkWidget *menu;
+ GtkWidget *add_edit_dialog;
+ GtkWidget *add_edit_entry;
+ GSettings *settings;
};
-
typedef struct _charpick_button_cb_data charpick_button_cb_data;
/* This is the data type for the button callback function. */
@@ -43,24 +42,23 @@ struct _charpick_button_cb_data {
charpick_data * p_curr_data;
};
-
-void start_callback_update(void);
+void start_callback_update (void);
void register_stock_for_edit (void);
-void build_table (charpick_data *curr_data);
+void build_table (charpick_data *curr_data);
void add_to_popup_menu (charpick_data *curr_data);
void populate_menu (charpick_data *curr_data);
void save_chartable (charpick_data *curr_data);
-void show_preferences_dialog (GtkAction *action,
- charpick_data *curr_data);
+void show_preferences_dialog (GtkAction *action,
+ charpick_data *curr_data);
-void add_edit_dialog_create (charpick_data *curr_data,
- gchar *string,
- gchar *title);
+void add_edit_dialog_create (charpick_data *curr_data,
+ gchar *string,
+ gchar *title);
void set_atk_name_description (GtkWidget *widget,
- const char *name,
- const char *description);
-gboolean key_writable (MatePanelApplet *applet, const char *key);
-
+ const char *name,
+ const char *description);
+gboolean key_writable (MatePanelApplet *applet,
+ const char *key);
#endif /* __CHARPICK_H__ */
diff --git a/charpick/properties.c b/charpick/properties.c
index 60b841b4..66c13a68 100644
--- a/charpick/properties.c
+++ b/charpick/properties.c
@@ -18,557 +18,567 @@
void
register_stock_for_edit (void)
{
- static gboolean registered = FALSE;
- if (!registered)
- {
- GtkIconFactory *factory;
- GtkIconSet *icons;
-
- static const GtkStockItem edit_item [] = {
- { CHARPICK_STOCK_EDIT, N_("_Edit"), 0, 0, GETTEXT_PACKAGE },
- };
- icons = gtk_icon_factory_lookup_default ("gtk-preferences");
- factory = gtk_icon_factory_new ();
- gtk_icon_factory_add (factory, CHARPICK_STOCK_EDIT, icons);
- gtk_icon_factory_add_default (factory);
- gtk_stock_add_static (edit_item, 1);
- registered = TRUE;
- }
+ static gboolean registered = FALSE;
+ if (!registered)
+ {
+ GtkIconFactory *factory;
+ GtkIconSet *icons;
+
+ static const GtkStockItem edit_item [] = {
+ { CHARPICK_STOCK_EDIT, N_("_Edit"), 0, 0, GETTEXT_PACKAGE },
+ };
+ icons = gtk_icon_factory_lookup_default ("gtk-preferences");
+ factory = gtk_icon_factory_new ();
+ gtk_icon_factory_add (factory,
+ CHARPICK_STOCK_EDIT,
+ icons);
+ gtk_icon_factory_add_default (factory);
+ gtk_stock_add_static (edit_item, 1);
+ registered = TRUE;
+ }
}
-#if 0
-static void
-set_atk_relation (GtkWidget *label, GtkWidget *widget)
-{
- AtkObject *atk_widget;
- AtkObject *atk_label;
- AtkRelationSet *relation_set;
- AtkRelation *relation;
- AtkObject *targets[1];
-
- atk_widget = gtk_widget_get_accessible (widget);
- atk_label = gtk_widget_get_accessible (label);
-
- /* set label-for relation */
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
-
- /* return if gail is not loaded */
- if (GTK_IS_ACCESSIBLE (atk_widget) == FALSE)
- return;
-
- /* set label-by relation */
- relation_set = atk_object_ref_relation_set (atk_widget);
- targets[0] = atk_label;
- relation = atk_relation_new (targets, 1, ATK_RELATION_LABELLED_BY);
- atk_relation_set_add (relation_set, relation);
- g_object_unref (G_OBJECT (relation));
-}
-#endif /* 0 */
-
/* sets accessible name and description */
static void
-set_access_namedesc (GtkWidget *widget, const gchar *name, const gchar *desc)
+set_access_namedesc (GtkWidget *widget,
+ const gchar *name,
+ const gchar *desc)
{
AtkObject *obj;
obj = gtk_widget_get_accessible (widget);
if (! GTK_IS_ACCESSIBLE (obj))
- return;
+ return;
- if ( desc )
- atk_object_set_description (obj, desc);
- if ( name )
- atk_object_set_name (obj, name);
+ if (desc)
+ atk_object_set_description (obj, desc);
+ if (name)
+ atk_object_set_name (obj, name);
}
void
add_edit_dialog_create (charpick_data *curr_data, gchar *string, gchar *title)
{
- GtkWidget *dialog;
- GtkWidget *entry;
- GtkWidget *dbox;
- GtkWidget *vbox, *hbox;
- GtkWidget *label;
-
- dialog = gtk_dialog_new_with_buttons (_(title), GTK_WINDOW (curr_data->propwindow),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- "gtk-cancel", GTK_RESPONSE_CANCEL,
- "gtk-ok", GTK_RESPONSE_OK,
- NULL);
-
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (curr_data->propwindow));
- gtk_widget_set_sensitive (curr_data->propwindow, FALSE);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area(GTK_DIALOG (dialog))), 2);
-
- dbox = gtk_dialog_get_content_area(GTK_DIALOG (dialog));
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- gtk_box_pack_start (GTK_BOX (dbox), vbox, TRUE, TRUE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
-
- label = gtk_label_new_with_mnemonic (_("_Palette:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- entry = gtk_entry_new ();
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
- gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
-
- set_access_namedesc (entry, _("Palette entry"),
- _("Modify a palette by adding or removing characters"));
- if (string)
- gtk_entry_set_text (GTK_ENTRY (entry), string);
-
- curr_data->add_edit_dialog = dialog;
- curr_data->add_edit_entry = entry;
+ GtkWidget *dialog;
+ GtkWidget *entry;
+ GtkWidget *dbox;
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *label;
+
+ dialog = gtk_dialog_new_with_buttons (_(title),
+ GTK_WINDOW (curr_data->propwindow),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ "gtk-cancel", GTK_RESPONSE_CANCEL,
+ "gtk-ok", GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ GTK_WINDOW (curr_data->propwindow));
+ gtk_widget_set_sensitive (curr_data->propwindow, FALSE);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
+
+ dbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+ gtk_box_pack_start (GTK_BOX (dbox), vbox, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+
+ label = gtk_label_new_with_mnemonic (_("_Palette:"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ entry = gtk_entry_new ();
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
+
+ set_access_namedesc (entry, _("Palette entry"),
+ _("Modify a palette by adding or removing characters"));
+ if (string)
+ gtk_entry_set_text (GTK_ENTRY (entry), string);
+
+ curr_data->add_edit_dialog = dialog;
+ curr_data->add_edit_entry = entry;
}
static void
-add_palette_cb (GtkDialog *dialog, int response_id, charpick_data *curr_data)
+add_palette_cb (GtkDialog *dialog,
+ int response_id,
+ charpick_data *curr_data)
{
- GList *list = curr_data->chartable;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- GtkTreePath *path;
- char *new;
-
- gtk_widget_set_sensitive (curr_data->propwindow, TRUE);
-
- if (response_id != GTK_RESPONSE_OK) {
- gtk_widget_destroy (curr_data->add_edit_dialog);
- return;
- }
-
- new = gtk_editable_get_chars (GTK_EDITABLE (curr_data->add_edit_entry), 0, -1);
-
- gtk_widget_destroy (curr_data->add_edit_dialog);
-
- if (!new || strlen (new) == 0)
- return;
-
- list = g_list_append (list, new);
-
- if (curr_data->chartable == NULL) {
- curr_data->chartable = list;
- curr_data->charlist = curr_data->chartable->data;
- build_table (curr_data);
-
- if (g_settings_is_writable (curr_data->settings, "current-list"))
- g_settings_set_string (curr_data->settings,
- "current-list",
- curr_data->charlist);
- }
-
- save_chartable (curr_data);
- populate_menu (curr_data);
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (curr_data->pref_tree));
-
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, new, 1, new, -1);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (curr_data->pref_tree));
- gtk_tree_selection_select_iter (selection, &iter);
-
- path = gtk_tree_model_get_path (model, &iter);
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (curr_data->pref_tree), path,
- NULL, FALSE, 0.0, 0.0);
-
- gtk_tree_path_free (path);
+ GList *list = curr_data->chartable;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+ char *new;
+
+ gtk_widget_set_sensitive (curr_data->propwindow, TRUE);
+
+ if (response_id != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (curr_data->add_edit_dialog);
+ return;
+ }
+
+ new = gtk_editable_get_chars (GTK_EDITABLE (curr_data->add_edit_entry), 0, -1);
+
+ gtk_widget_destroy (curr_data->add_edit_dialog);
+
+ if (!new || strlen (new) == 0)
+ return;
+
+ list = g_list_append (list, new);
+
+ if (curr_data->chartable == NULL) {
+ curr_data->chartable = list;
+ curr_data->charlist = curr_data->chartable->data;
+ build_table (curr_data);
+
+ if (g_settings_is_writable (curr_data->settings, "current-list"))
+ g_settings_set_string (curr_data->settings,
+ "current-list",
+ curr_data->charlist);
+ }
+
+ save_chartable (curr_data);
+ populate_menu (curr_data);
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (curr_data->pref_tree));
+
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, new, 1, new, -1);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (curr_data->pref_tree));
+ gtk_tree_selection_select_iter (selection, &iter);
+
+ path = gtk_tree_model_get_path (model, &iter);
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (curr_data->pref_tree),
+ path, NULL, FALSE, 0.0, 0.0);
+
+ gtk_tree_path_free (path);
}
static void
-edit_palette_cb (GtkDialog *dialog, int response_id, charpick_data *curr_data)
+edit_palette_cb (GtkDialog *dialog,
+ int response_id,
+ charpick_data *curr_data)
{
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- GtkTreeModel *model;
- GList *list;
- char *new, *charlist;
-
- gtk_widget_set_sensitive (curr_data->propwindow, TRUE);
-
- if (response_id != GTK_RESPONSE_OK) {
- gtk_widget_destroy (curr_data->add_edit_dialog);
- return;
- }
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (curr_data->pref_tree));
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return;
-
- gtk_tree_model_get (model, &iter, 1, &charlist, -1);
-
- new = gtk_editable_get_chars (GTK_EDITABLE (curr_data->add_edit_entry), 0, -1);
-
- gtk_widget_destroy (curr_data->add_edit_dialog);
-
- if (!new || (g_ascii_strcasecmp (new, charlist) == 0))
- return;
-
- list = g_list_find (curr_data->chartable, charlist);
- list->data = new;
- save_chartable (curr_data);
- populate_menu (curr_data);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, new, 1, new, -1);
-
- if (g_ascii_strcasecmp (curr_data->charlist, charlist) == 0) {
- curr_data->charlist = new;
- build_table (curr_data);
-
- if (g_settings_is_writable (curr_data->settings, "current-list"))
- g_settings_set_string (curr_data->settings, "current-list", curr_data->charlist);
- }
-
- g_free (charlist);
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GList *list;
+ char *new;
+ char *charlist;
+
+ gtk_widget_set_sensitive (curr_data->propwindow, TRUE);
+
+ if (response_id != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (curr_data->add_edit_dialog);
+ return;
+ }
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (curr_data->pref_tree));
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+
+ gtk_tree_model_get (model, &iter, 1, &charlist, -1);
+
+ new = gtk_editable_get_chars (GTK_EDITABLE (curr_data->add_edit_entry), 0, -1);
+
+ gtk_widget_destroy (curr_data->add_edit_dialog);
+
+ if (!new || (g_ascii_strcasecmp (new, charlist) == 0))
+ return;
+
+ list = g_list_find (curr_data->chartable, charlist);
+ list->data = new;
+ save_chartable (curr_data);
+ populate_menu (curr_data);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, new, 1, new, -1);
+
+ if (g_ascii_strcasecmp (curr_data->charlist, charlist) == 0) {
+ curr_data->charlist = new;
+ build_table (curr_data);
+
+ if (g_settings_is_writable (curr_data->settings, "current-list"))
+ g_settings_set_string (curr_data->settings,
+ "current-list",
+ curr_data->charlist);
+ }
+
+ g_free (charlist);
}
static void
-add_palette (GtkButton *buttonk, charpick_data *curr_data)
+add_palette (GtkButton *buttonk,
+ charpick_data *curr_data)
{
- if (curr_data->add_edit_dialog == NULL) {
- add_edit_dialog_create (curr_data, NULL, _("Add Palette"));
-
- g_signal_connect (curr_data->add_edit_dialog,
- "response",
- G_CALLBACK (add_palette_cb),
- curr_data);
-
- g_signal_connect (curr_data->add_edit_dialog,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &curr_data->add_edit_dialog);
-
- gtk_widget_show_all (curr_data->add_edit_dialog);
- } else {
- gtk_window_set_screen (GTK_WINDOW (curr_data->add_edit_dialog),
- gtk_widget_get_screen (GTK_WIDGET (curr_data->applet)));
-
- gtk_window_present (GTK_WINDOW (curr_data->add_edit_dialog));
- }
+ if (curr_data->add_edit_dialog == NULL) {
+ add_edit_dialog_create (curr_data, NULL, _("Add Palette"));
+
+ g_signal_connect (curr_data->add_edit_dialog,
+ "response",
+ G_CALLBACK (add_palette_cb),
+ curr_data);
+
+ g_signal_connect (curr_data->add_edit_dialog,
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &curr_data->add_edit_dialog);
+
+ gtk_widget_show_all (curr_data->add_edit_dialog);
+ } else {
+ gtk_window_set_screen (GTK_WINDOW (curr_data->add_edit_dialog),
+ gtk_widget_get_screen (GTK_WIDGET (curr_data->applet)));
+
+ gtk_window_present (GTK_WINDOW (curr_data->add_edit_dialog));
+ }
}
static void
-edit_palette (GtkButton *button, charpick_data *curr_data)
+edit_palette (GtkButton *button,
+ charpick_data *curr_data)
{
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- GtkTreeModel *model;
- char *charlist;
-
- if (curr_data->add_edit_dialog == NULL) {
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (curr_data->pref_tree));
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return;
-
- gtk_tree_model_get (model, &iter, 1, &charlist, -1);
-
- add_edit_dialog_create (curr_data, charlist, _("Edit Palette"));
-
- g_signal_connect (curr_data->add_edit_dialog,
- "response",
- G_CALLBACK (edit_palette_cb),
- curr_data);
-
- g_signal_connect (curr_data->add_edit_dialog,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &curr_data->add_edit_dialog);
-
- gtk_widget_show_all (curr_data->add_edit_dialog);
- } else {
- gtk_window_set_screen (GTK_WINDOW (curr_data->add_edit_dialog),
- gtk_widget_get_screen (GTK_WIDGET (curr_data->applet)));
-
- gtk_window_present (GTK_WINDOW (curr_data->add_edit_dialog));
- }
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ char *charlist;
+
+ if (curr_data->add_edit_dialog == NULL) {
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (curr_data->pref_tree));
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+
+ gtk_tree_model_get (model, &iter, 1, &charlist, -1);
+
+ add_edit_dialog_create (curr_data, charlist, _("Edit Palette"));
+
+ g_signal_connect (curr_data->add_edit_dialog,
+ "response",
+ G_CALLBACK (edit_palette_cb),
+ curr_data);
+
+ g_signal_connect (curr_data->add_edit_dialog,
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &curr_data->add_edit_dialog);
+
+ gtk_widget_show_all (curr_data->add_edit_dialog);
+ } else {
+ gtk_window_set_screen (GTK_WINDOW (curr_data->add_edit_dialog),
+ gtk_widget_get_screen (GTK_WIDGET (curr_data->applet)));
+
+ gtk_window_present (GTK_WINDOW (curr_data->add_edit_dialog));
+ }
}
static void
-delete_palette (GtkButton *button, charpick_data *curr_data)
+delete_palette (GtkButton *button,
+ charpick_data *curr_data)
{
- GtkTreeSelection *selection;
- GtkTreeIter iter, next;
- GtkTreeModel *model;
- gchar *charlist;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (curr_data->pref_tree));
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return;
-
- gtk_tree_model_get (model, &iter, 1, &charlist, -1);
-
- curr_data->chartable = g_list_remove (curr_data->chartable, charlist);
-
- if (g_ascii_strcasecmp (curr_data->charlist, charlist) == 0) {
- curr_data->charlist = curr_data->chartable != NULL ?
- curr_data->chartable->data : "";
- if (g_settings_is_writable (curr_data->settings, "current-list"))
- g_settings_set_string (curr_data->settings, "current-list", curr_data->charlist);
- }
- g_free (charlist);
-
- save_chartable (curr_data);
- populate_menu (curr_data);
-
- gtk_widget_grab_focus (curr_data->pref_tree);
- next = iter;
- if (gtk_tree_model_iter_next (model, &next) )
- gtk_tree_selection_select_iter (selection, &next);
- else {
- GtkTreePath *path;
- path = gtk_tree_model_get_path (model, &iter);
- if (gtk_tree_path_prev (path))
- gtk_tree_selection_select_path (selection, path);
- gtk_tree_path_free (path);
- }
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
-
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreeIter next;
+ GtkTreeModel *model;
+ gchar *charlist;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (curr_data->pref_tree));
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+
+ gtk_tree_model_get (model, &iter, 1, &charlist, -1);
+
+ curr_data->chartable = g_list_remove (curr_data->chartable, charlist);
+
+ if (g_ascii_strcasecmp (curr_data->charlist, charlist) == 0) {
+ curr_data->charlist = curr_data->chartable != NULL ?
+ curr_data->chartable->data : "";
+ if (g_settings_is_writable (curr_data->settings, "current-list"))
+ g_settings_set_string (curr_data->settings,
+ "current-list",
+ curr_data->charlist);
+ }
+ g_free (charlist);
+
+ save_chartable (curr_data);
+ populate_menu (curr_data);
+
+ gtk_widget_grab_focus (curr_data->pref_tree);
+ next = iter;
+ if (gtk_tree_model_iter_next (model, &next) )
+ gtk_tree_selection_select_iter (selection, &next);
+ else {
+ GtkTreePath *path;
+ path = gtk_tree_model_get_path (model, &iter);
+ if (gtk_tree_path_prev (path))
+ gtk_tree_selection_select_path (selection, path);
+ gtk_tree_path_free (path);
+ }
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
}
static void
-selection_changed (GtkTreeSelection *selection, gpointer data)
+selection_changed (GtkTreeSelection *selection,
+ gpointer data)
{
- GtkWidget *scrolled = data;
- GtkWidget *edit_button, *delete_button;
- gboolean selected;
-
- selected = gtk_tree_selection_get_selected (selection, NULL, NULL);
- edit_button = g_object_get_data (G_OBJECT (scrolled), "edit_button");
- gtk_widget_set_sensitive (edit_button, selected);
- delete_button = g_object_get_data (G_OBJECT (scrolled), "delete_button");
- gtk_widget_set_sensitive (delete_button, selected);
+ GtkWidget *scrolled = data;
+ GtkWidget *edit_button, *delete_button;
+ gboolean selected;
+
+ selected = gtk_tree_selection_get_selected (selection, NULL, NULL);
+ edit_button = g_object_get_data (G_OBJECT (scrolled), "edit_button");
+ gtk_widget_set_sensitive (edit_button, selected);
+ delete_button = g_object_get_data (G_OBJECT (scrolled), "delete_button");
+ gtk_widget_set_sensitive (delete_button, selected);
}
static GtkWidget *
-create_palettes_tree (charpick_data *curr_data, GtkWidget *label)
+create_palettes_tree (charpick_data *curr_data,
+ GtkWidget *label)
{
- GtkWidget *scrolled;
- GtkWidget *tree;
- GtkListStore *model;
- GtkCellRenderer *cell;
- GtkTreeViewColumn *column;
- GList *list = curr_data->chartable;
- GtkTreeSelection *selection;
-
- scrolled = gtk_scrolled_window_new (NULL,NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
- tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
- curr_data->pref_tree = tree;
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree);
- gtk_container_add (GTK_CONTAINER (scrolled), tree);
- set_access_namedesc (tree,
- _("Palettes list"),
- _("List of available palettes"));
- g_object_unref (G_OBJECT (model));
- cell = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("hello",
- cell,
- "text", 0,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree), FALSE);
-
- while (list) {
- GtkTreeIter iter;
- gchar *charlist = list->data;
-
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, charlist, 1, charlist, -1);
+ GtkWidget *scrolled;
+ GtkWidget *tree;
+ GtkListStore *model;
+ GtkCellRenderer *cell;
+ GtkTreeViewColumn *column;
+ GList *list = curr_data->chartable;
+ GtkTreeSelection *selection;
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+ model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
+ tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+ curr_data->pref_tree = tree;
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree);
+ gtk_container_add (GTK_CONTAINER (scrolled), tree);
+ set_access_namedesc (tree,
+ _("Palettes list"),
+ _("List of available palettes"));
+ g_object_unref (G_OBJECT (model));
+ cell = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes ("hello",
+ cell,
+ "text",
+ 0, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree), FALSE);
+
+ while (list) {
+ GtkTreeIter iter;
+ gchar *charlist = list->data;
- list = g_list_next (list);
- }
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter, 0,
+ charlist, 1,
+ charlist, -1);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
- g_signal_connect (G_OBJECT (selection), "changed",
- G_CALLBACK (selection_changed), scrolled);
+ list = g_list_next (list);
+ }
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (selection_changed),
+ scrolled);
- return scrolled;
+ return scrolled;
}
static GtkWidget *
-create_hig_catagory (GtkWidget *main_box, gchar *title)
+create_hig_catagory (GtkWidget *main_box,
+ gchar *title)
{
- GtkWidget *vbox, *vbox2, *hbox;
- GtkWidget *label;
- gchar *tmp;
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (main_box), vbox, TRUE, TRUE, 0);
-
- tmp = g_strdup_printf ("<b>%s</b>", title);
- label = gtk_label_new (NULL);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_label_set_markup (GTK_LABEL (label), tmp);
- g_free (tmp);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
-
- label = gtk_label_new (" ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
-
- return vbox2;
-
+ GtkWidget *vbox, *vbox2, *hbox;
+ GtkWidget *label;
+ gchar *tmp;
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_box_pack_start (GTK_BOX (main_box), vbox, TRUE, TRUE, 0);
+
+ tmp = g_strdup_printf ("<b>%s</b>", title);
+ label = gtk_label_new (NULL);
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gtk_label_set_markup (GTK_LABEL (label), tmp);
+ g_free (tmp);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+
+ label = gtk_label_new (" ");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
+
+ return vbox2;
}
-static void default_chars_frame_create(charpick_data *curr_data)
+static void
+default_chars_frame_create (charpick_data *curr_data)
{
- GtkWidget *dialog = curr_data->propwindow;
- GtkWidget *dbox, *vbox, *vbox1, *vbox2, *vbox3;
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *scrolled;
- GtkWidget *button;
-
- dbox = gtk_dialog_get_content_area(GTK_DIALOG (dialog));
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
- gtk_box_pack_start (GTK_BOX (dbox), vbox, TRUE, TRUE, 0);
-
- vbox1 = create_hig_catagory (vbox, _("Character Palette"));
-
- vbox3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (vbox1), vbox3, TRUE, TRUE, 0);
-
- label = gtk_label_new_with_mnemonic(_("_Palettes:"));
- gtk_box_pack_start(GTK_BOX(vbox3), label, FALSE, FALSE, 0);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_widget_show(label);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (vbox3), hbox, TRUE, TRUE, 0);
- scrolled = create_palettes_tree (curr_data, label);
- gtk_box_pack_start (GTK_BOX (hbox), scrolled, TRUE, TRUE, 0);
-
- vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
-
- button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
- "label", "gtk-add",
- "use-stock", TRUE,
- "use-underline", TRUE,
- NULL));
-
- gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (add_palette), curr_data);
- set_access_namedesc (button, _("Add button"),
- _("Click to add a new palette"));
+ GtkWidget *dialog = curr_data->propwindow;
+ GtkWidget *dbox;
+ GtkWidget *vbox;
+ GtkWidget *vbox1;
+ GtkWidget *vbox2;
+ GtkWidget *vbox3;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *scrolled;
+ GtkWidget *button;
+
+ dbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+ gtk_box_pack_start (GTK_BOX (dbox), vbox, TRUE, TRUE, 0);
+
+ vbox1 = create_hig_catagory (vbox, _("Character Palette"));
+
+ vbox3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_box_pack_start (GTK_BOX (vbox1), vbox3, TRUE, TRUE, 0);
+
+ label = gtk_label_new_with_mnemonic (_("_Palettes:"));
+ gtk_box_pack_start (GTK_BOX (vbox3), label, FALSE, FALSE, 0);
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gtk_widget_show (label);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_pack_start (GTK_BOX (vbox3), hbox, TRUE, TRUE, 0);
+ scrolled = create_palettes_tree (curr_data, label);
+ gtk_box_pack_start (GTK_BOX (hbox), scrolled, TRUE, TRUE, 0);
+
+ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
+
+ button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+ "label", "gtk-add",
+ "use-stock", TRUE,
+ "use-underline", TRUE,
+ NULL));
+
+ gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (add_palette),
+ curr_data);
+ set_access_namedesc (button, _("Add button"),
+ _("Click to add a new palette"));
- button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
- "label", CHARPICK_STOCK_EDIT,
- "use-stock", TRUE,
- "use-underline", TRUE,
- NULL));
-
- gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (edit_palette), curr_data);
- g_object_set_data (G_OBJECT (scrolled), "edit_button", button);
- set_access_namedesc (button, _("Edit button"),
- _("Click to edit the selected palette"));
+ button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+ "label", CHARPICK_STOCK_EDIT,
+ "use-stock", TRUE,
+ "use-underline", TRUE,
+ NULL));
+
+ gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (edit_palette),
+ curr_data);
+ g_object_set_data (G_OBJECT (scrolled),
+ "edit_button", button);
+ set_access_namedesc (button, _("Edit button"),
+ _("Click to edit the selected palette"));
- button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
- "label", "gtk-delete",
- "use-stock", TRUE,
- "use-underline", TRUE,
- NULL));
-
- gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (delete_palette), curr_data);
- g_object_set_data (G_OBJECT (scrolled), "delete_button", button);
- set_access_namedesc (button, _("Delete button"),
- _("Click to delete the selected palette"));
-
- if ( ! g_settings_is_writable (curr_data->settings, "chartable"))
- gtk_widget_set_sensitive (vbox3, FALSE);
-
- return;
+ button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+ "label", "gtk-delete",
+ "use-stock", TRUE,
+ "use-underline", TRUE,
+ NULL));
+
+ gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (delete_palette),
+ curr_data);
+ g_object_set_data (G_OBJECT (scrolled),
+ "delete_button", button);
+ set_access_namedesc (button, _("Delete button"),
+ _("Click to delete the selected palette"));
+
+ if (! g_settings_is_writable (curr_data->settings, "chartable"))
+ gtk_widget_set_sensitive (vbox3, FALSE);
+
+ return;
}
static void
-phelp_cb (GtkDialog *dialog, gint tab, gpointer data)
+phelp_cb (GtkDialog *dialog,
+ gint tab,
+ gpointer data)
{
- GError *error = NULL;
-
- gtk_show_uri_on_window (GTK_WINDOW (dialog),
- "help:mate-char-palette/charpick-prefs",
- gtk_get_current_event_time (),
- &error);
-
- if (error) { /* FIXME: the user needs to see this */
- g_warning ("help error: %s\n", error->message);
- g_error_free (error);
- error = NULL;
- }
+ GError *error = NULL;
+
+ gtk_show_uri_on_window (GTK_WINDOW (dialog),
+ "help:mate-char-palette/charpick-prefs",
+ gtk_get_current_event_time (),
+ &error);
+
+ if (error) { /* FIXME: the user needs to see this */
+ g_warning ("help error: %s\n", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
}
static void
-response_cb (GtkDialog *dialog, gint id, gpointer data)
+response_cb (GtkDialog *dialog,
+ gint id,
+ gpointer data)
{
- charpick_data *curr_data = data;
+ charpick_data *curr_data = data;
- if(id == GTK_RESPONSE_HELP){
- phelp_cb (dialog,id,data);
- return;
- }
-
- gtk_widget_destroy (curr_data->propwindow);
- curr_data->propwindow = NULL;
-
+ if (id == GTK_RESPONSE_HELP) {
+ phelp_cb (dialog, id, data);
+ return;
+ }
+
+ gtk_widget_destroy (curr_data->propwindow);
+ curr_data->propwindow = NULL;
}
void
show_preferences_dialog (GtkAction *action,
- charpick_data *curr_data)
+ charpick_data *curr_data)
{
- if (curr_data->propwindow) {
+ if (curr_data->propwindow) {
+ gtk_window_set_screen (GTK_WINDOW (curr_data->propwindow),
+ gtk_widget_get_screen (curr_data->applet));
+ gtk_window_present (GTK_WINDOW (curr_data->propwindow));
+ return;
+ }
+
+ curr_data->propwindow = gtk_dialog_new_with_buttons (_("Character Palette Preferences"),
+ NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ "gtk-close", GTK_RESPONSE_CLOSE,
+ "gtk-help", GTK_RESPONSE_HELP,
+ NULL);
gtk_window_set_screen (GTK_WINDOW (curr_data->propwindow),
- gtk_widget_get_screen (curr_data->applet));
- gtk_window_present (GTK_WINDOW (curr_data->propwindow));
- return;
- }
-
- curr_data->propwindow = gtk_dialog_new_with_buttons (_("Character Palette Preferences"),
- NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- "gtk-close", GTK_RESPONSE_CLOSE,
- "gtk-help", GTK_RESPONSE_HELP,
- NULL);
- gtk_window_set_screen (GTK_WINDOW (curr_data->propwindow),
- gtk_widget_get_screen (curr_data->applet));
- gtk_window_set_default_size (GTK_WINDOW (curr_data->propwindow), 350, 350);
- gtk_container_set_border_width (GTK_CONTAINER (curr_data->propwindow), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area(GTK_DIALOG (curr_data->propwindow))), 2);
- gtk_dialog_set_default_response (GTK_DIALOG (curr_data->propwindow), GTK_RESPONSE_CLOSE);
-
- default_chars_frame_create(curr_data);
- g_signal_connect (G_OBJECT (curr_data->propwindow), "response",
- G_CALLBACK (response_cb), curr_data);
-
- gtk_widget_show_all (curr_data->propwindow);
+ gtk_widget_get_screen (curr_data->applet));
+ gtk_window_set_default_size (GTK_WINDOW (curr_data->propwindow), 350, 350);
+ gtk_container_set_border_width (GTK_CONTAINER (curr_data->propwindow), 5);
+ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (curr_data->propwindow))), 2);
+ gtk_dialog_set_default_response (GTK_DIALOG (curr_data->propwindow), GTK_RESPONSE_CLOSE);
+
+ default_chars_frame_create (curr_data);
+ g_signal_connect (G_OBJECT (curr_data->propwindow), "response",
+ G_CALLBACK (response_cb), curr_data);
+
+ gtk_widget_show_all (curr_data->propwindow);
}