Skip to content

Commit

Permalink
Create color scheme menu item with Glade
Browse files Browse the repository at this point in the history
Now there is a dialog instead of a menu for selecting the color
schemes, the item under View->Editor can be created with Glade like the
rest of the menu.
  • Loading branch information
b4n committed May 26, 2012
1 parent ac27a65 commit e87f393
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 25 deletions.
18 changes: 18 additions & 0 deletions data/geany.glade
Expand Up @@ -452,6 +452,12 @@
<column type="gchararray"/>
</columns>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-select-color</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image4060">
<property name="visible">True</property>
<property name="can_focus">False</property>
Expand Down Expand Up @@ -8305,6 +8311,18 @@
<child type="submenu">
<object class="GtkMenu" id="menu_view_editor1_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="menu_color_schemes">
<property name="label" translatable="yes">_Color Schemes</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="image">image2</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_menu_color_schemes_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="menu_markers_margin1">
<property name="use_action_appearance">False</property>
Expand Down
7 changes: 7 additions & 0 deletions src/callbacks.c
Expand Up @@ -63,6 +63,7 @@
#include "plugins.h"
#include "log.h"
#include "toolbar.h"
#include "highlighting.h"
#include "pluginutils.h"


Expand Down Expand Up @@ -801,6 +802,12 @@ G_MODULE_EXPORT void on_show_messages_window1_toggled(GtkCheckMenuItem *checkmen
}


G_MODULE_EXPORT void on_menu_color_schemes_activate(GtkImageMenuItem *imagemenuitem, gpointer user_data)
{
highlighting_show_color_scheme_dialog();
}


G_MODULE_EXPORT void on_markers_margin1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
{
if (ignore_callback)
Expand Down
4 changes: 4 additions & 0 deletions src/callbacks.h
Expand Up @@ -177,6 +177,10 @@ G_MODULE_EXPORT void
on_show_messages_window1_toggled (GtkCheckMenuItem *checkmenuitem,
gpointer user_data);

G_MODULE_EXPORT void
on_menu_color_schemes_activate (GtkImageMenuItem *imagemenuitem,
gpointer user_data);

G_MODULE_EXPORT void
on_construct_completion1_activate (GtkMenuItem *menuitem,
gpointer user_data);
Expand Down
21 changes: 1 addition & 20 deletions src/highlighting.c
Expand Up @@ -1312,7 +1312,7 @@ static void on_color_scheme_dialog_response(GtkWidget *dialog,
}


static void show_color_scheme_dialog(void)
void highlighting_show_color_scheme_dialog(void)
{
static GtkWidget *dialog = NULL;
GtkListStore *store = gtk_list_store_new(SCHEME_COLUMNS,
Expand Down Expand Up @@ -1358,25 +1358,6 @@ static void show_color_scheme_dialog(void)
}


static void create_color_scheme_menu(void)
{
GtkWidget *item, *menu;

menu = ui_lookup_widget(main_widgets.window, "menu_view_editor1_menu");
item = ui_image_menu_item_new(GTK_STOCK_SELECT_COLOR, _("_Color Schemes"));
gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), item);

g_signal_connect(item, "activate", G_CALLBACK(show_color_scheme_dialog), NULL);
gtk_widget_show(item);
}


void highlighting_init(void)
{
create_color_scheme_menu();
}


/** Checks whether the given style is a string for the given lexer.
*
* @param lexer Scintilla lexer type (@c SCLEX_*).
Expand Down
4 changes: 2 additions & 2 deletions src/highlighting.h
Expand Up @@ -41,8 +41,6 @@ typedef struct GeanyLexerStyle
GeanyLexerStyle;


void highlighting_init(void);

void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *configh);

void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft);
Expand All @@ -55,6 +53,8 @@ gboolean highlighting_is_string_style(gint lexer, gint style);
gboolean highlighting_is_comment_style(gint lexer, gint style);
gboolean highlighting_is_code_style(gint lexer, gint style);

void highlighting_show_color_scheme_dialog(void);

G_END_DECLS

#endif
3 changes: 0 additions & 3 deletions src/main.c
Expand Up @@ -1040,9 +1040,6 @@ gint main(gint argc, gchar **argv)
keybindings_init();
notebook_init();
filetypes_init();
/* depends on filetypes_array being not NULL so must be after
* filetypes_init(). */
highlighting_init();
templates_init();
navqueue_init();
document_init_doclist();
Expand Down

0 comments on commit e87f393

Please sign in to comment.