~ubuntu-branches/ubuntu/utopic/geany/utopic

« back to all changes in this revision

Viewing changes to src/toolbar.c

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-12-10 07:43:26 UTC
  • mfrom: (3.3.7 sid)
  • Revision ID: package-import@ubuntu.com-20111210074326-s8yqbew5i20h33tf
Tags: 0.21-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  - debian/patches/20_use_evince_viewer.patch:
     + use evince as viewer for pdf and dvi files
  - debian/patches/20_use_x_terminal_emulator.patch:
     + use x-terminal-emulator as terminal
  - debian/control
     + Add breaks on geany-plugins-common << 0.20
* Also fixes bugs:
  - Filter for MATLAB/Octave files filters everythign (LP: 885505)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *      toolbar.c - this file is part of Geany, a fast and lightweight IDE
3
3
 *
4
 
 *      Copyright 2009-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5
 
 *      Copyright 2009-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
 
4
 *      Copyright 2009-2011 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
 
5
 *      Copyright 2009-2011 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
6
6
 *
7
7
 *      This program is free software; you can redistribute it and/or modify
8
8
 *      it under the terms of the GNU General Public License as published by
18
18
 *      along with this program; if not, write to the Free Software
19
19
 *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
20
 *
21
 
 * $Id: toolbar.c 4941 2010-05-22 19:39:03Z eht16 $
 
21
 * $Id: toolbar.c 5721 2011-04-13 12:59:20Z ntrel $
22
22
 */
23
23
 
24
24
/**
54
54
const GtkActionEntry ui_entries[] = {
55
55
        /* custom actions defined in toolbar_init(): "New", "Open", "SearchEntry", "GotoEntry", "Build" */
56
56
        { "Save", GTK_STOCK_SAVE, NULL, NULL, N_("Save the current file"), G_CALLBACK(on_toolbutton_save_clicked) },
 
57
        { "SaveAs", GTK_STOCK_SAVE_AS, NULL, NULL, N_("Save as"), G_CALLBACK(on_save_as1_activate) },
57
58
        { "SaveAll", GEANY_STOCK_SAVE_ALL, NULL, NULL, N_("Save all open files"), G_CALLBACK(on_save_all1_activate) },
58
59
        { "Reload", GTK_STOCK_REVERT_TO_SAVED, NULL, NULL, N_("Reload the current file from disk"), G_CALLBACK(on_toolbutton_reload_clicked) },
59
60
        { "Close", GTK_STOCK_CLOSE, NULL, NULL, N_("Close the current file"), G_CALLBACK(on_toolbutton_close_clicked) },
176
177
        GSList *l;
177
178
        GtkWidget *entry;
178
179
        GError *error = NULL;
179
 
        const gchar *filename;
 
180
        gchar *filename;
180
181
        static guint merge_id = 0;
181
182
        GtkWidget *toolbar_new_file_menu = NULL;
182
183
        GtkWidget *toolbar_recent_files_menu = NULL;
225
226
                        g_error_free(error);
226
227
                        error = NULL;
227
228
 
228
 
                        filename = utils_build_path(app->datadir, "ui_toolbar.xml", NULL);
 
229
                        setptr(filename, utils_build_path(app->datadir, "ui_toolbar.xml", NULL));
229
230
                        merge_id = gtk_ui_manager_add_ui_from_file(uim, filename, &error);
230
231
                }
 
232
                g_free(filename);
231
233
        }
232
234
        if (error != NULL)
233
235
        {
312
314
        if (entry != NULL)
313
315
                g_signal_connect(entry, "motion-notify-event", G_CALLBACK(on_motion_event), NULL);
314
316
 
315
 
 
316
317
        return main_widgets.toolbar;
317
318
}
318
319
 
380
381
        action_searchentry = geany_entry_action_new(
381
382
                "SearchEntry", _("Search"), _("Find the entered text in the current file"), FALSE);
382
383
        g_signal_connect(action_searchentry, "entry-activate",
383
 
                G_CALLBACK(on_toolbar_search_entry_changed), GINT_TO_POINTER(FALSE));
 
384
                G_CALLBACK(on_toolbar_search_entry_activate), GINT_TO_POINTER(FALSE));
 
385
        g_signal_connect(action_searchentry, "entry-activate-backward",
 
386
                G_CALLBACK(on_toolbar_search_entry_activate), GINT_TO_POINTER(TRUE));
384
387
        g_signal_connect(action_searchentry, "entry-changed",
385
 
                G_CALLBACK(on_toolbar_search_entry_changed), GINT_TO_POINTER(TRUE));
 
388
                G_CALLBACK(on_toolbar_search_entry_changed), NULL);
386
389
        gtk_action_group_add_action(group, action_searchentry);
387
390
 
388
391
        action_gotoentry = geany_entry_action_new(
479
482
        /* we need to adjust the packing flags for the menubar to expand it if it is alone in the
480
483
         * hbox and not expand it if the toolbar is appended */
481
484
        gtk_box_set_child_packing(GTK_BOX(hbox_menubar), menubar,
482
 
                ! toolbar_prefs.append_to_menu, ! toolbar_prefs.append_to_menu, 0, GTK_PACK_START);
 
485
                ! (toolbar_prefs.visible && toolbar_prefs.append_to_menu),
 
486
                ! (toolbar_prefs.visible && toolbar_prefs.append_to_menu), 0, GTK_PACK_START);
483
487
}
484
488
 
485
489
 
789
793
                return;
790
794
 
791
795
        gtk_tree_model_get(model, &iter, TB_EDITOR_COL_ACTION, &name, -1);
792
 
        if (! NZV(name))
 
796
        if (G_UNLIKELY(! NZV(name)))
793
797
                return;
794
798
 
795
799
        atom = gdk_atom_intern(tb_editor_dnd_targets[0].target, FALSE);
865
869
 
866
870
        if (utils_str_equal(action_name, TB_EDITOR_SEPARATOR))
867
871
                g_string_append_printf(data, "\t\t<separator/>\n");
868
 
        else if (NZV(action_name))
 
872
        else if (G_LIKELY(NZV(action_name)))
869
873
                g_string_append_printf(data, "\t\t<toolitem action='%s' />\n", action_name);
870
874
 
871
875
        g_free(action_name);
887
891
A list of available actions can be found in the documentation included with Geany or\n\
888
892
at http://www.geany.org/manual/current/index.html#customizing-the-toolbar.\n-->\n\
889
893
\t<toolbar name='GeanyToolbar'>\n";
890
 
        const gchar *filename = utils_build_path(app->configdir, "ui_toolbar.xml", NULL);
 
894
        gchar *filename;
891
895
        GString *str = g_string_new(template);
892
896
 
893
897
        gtk_tree_model_foreach(GTK_TREE_MODEL(tbw->store_used), tb_editor_foreach_used, str);
896
900
 
897
901
        toolbar_reload(str->str);
898
902
 
 
903
        filename = utils_build_path(app->configdir, "ui_toolbar.xml", NULL);
899
904
        utils_write_file(filename, str->str);
 
905
        g_free(filename);
900
906
 
901
907
        g_string_free(str, TRUE);
902
908
}