Beispiel #1
0
static void
set_style_scheme_search_path ()
{
	GtkSourceStyleSchemeManager *manager = gtk_source_style_scheme_manager_get_default ();

	gchar *path = gitg_dirs_get_data_filename ("styles", NULL);
	gtk_source_style_scheme_manager_prepend_search_path (manager, path);
	g_free (path);
}
Beispiel #2
0
void main_window_create(char **argv, gint argc)
{
  main_window.is_app_closing = FALSE;
  main_window.prefmg = preferences_manager_new();
  main_window.tempmg = templates_manager_new();

  create_app_main_window(&main_window, _("gPHPEdit"));

  main_window.pbuilder = gtk_builder_new ();
  GError *error = NULL;
  guint res = gtk_builder_add_from_file (main_window.pbuilder, GPHPEDIT_UI_DIR "/gphpedit.ui", &error);
  if (!res) {
    g_critical ("Unable to load the UI file!");
    g_error_free(error);
    return ;
  }

  GtkWidget *prinbox = get_widget_from_builder(&main_window, "prinbox");
  gtk_widget_reparent (prinbox, GTK_WIDGET(main_window.window));

  /* add menu bar to main window */
  GtkWidget *menubox = get_widget_from_builder(&main_window, "menubox");
  gtk_widget_show (menubox);

  main_window.pmenu_hints = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);

  main_window.pmenu = menubar_new (&main_window);
  gtk_box_pack_start (GTK_BOX (menubox), main_window.pmenu, FALSE, FALSE, 0);
  gtk_widget_show_all (main_window.pmenu);

  GtkWidget *toolbox = get_widget_from_builder(&main_window, "toolbox");
  gtk_widget_show (toolbox);

  main_window.toolbar_main = toolbar_new (&main_window);
  gtk_box_pack_start (GTK_BOX (toolbox), main_window.toolbar_main, FALSE, FALSE, 0);
  if (get_preferences_manager_show_maintoolbar(main_window.prefmg)) gtk_widget_show (main_window.toolbar_main);

  main_window.symbolmg = symbol_manager_new();

  main_window_create_panes(&main_window);
  main_window_fill_panes(&main_window);
  main_window_create_appbar(&main_window);
  
  g_signal_connect (G_OBJECT (main_window.window), "delete_event", G_CALLBACK(main_window_delete_event), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "destroy", G_CALLBACK (main_window_destroy_event), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "key_press_event", G_CALLBACK (main_window_key_press_event), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "size_allocate", G_CALLBACK (main_window_resize), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "window-state-event", G_CALLBACK (main_window_state_changed), &main_window);
  g_signal_connect (G_OBJECT (main_window.window), "focus-in-event", G_CALLBACK (main_window_activate_focus), &main_window);

  main_window.stylemg = gtk_source_style_scheme_manager_new ();
  gchar *theme_dir = g_build_path (G_DIR_SEPARATOR_S, API_DIR, "themes", NULL);
  gtk_source_style_scheme_manager_prepend_search_path (main_window.stylemg, theme_dir);
  g_free(theme_dir);

  main_window.docmg = document_manager_new_full(argv, argc, &main_window);
  g_signal_connect (G_OBJECT (main_window.docmg), "new_document", G_CALLBACK(document_manager_new_document_cb), &main_window);
  g_signal_connect (G_OBJECT (main_window.docmg), "change_document", G_CALLBACK(document_manager_change_document_cb), &main_window);
  g_signal_connect (G_OBJECT (main_window.docmg), "close_document", G_CALLBACK(document_manager_close_document_cb), &main_window);
  g_signal_connect (G_OBJECT (main_window.docmg), "zoom_change", G_CALLBACK(document_manager_zoom_change_cb), &main_window);

  /* create side panel */
  create_side_panel(&main_window);

  update_app_title(&main_window, document_manager_get_current_documentable(main_window.docmg));

  gtk_widget_show(main_window.window);
}
/**
 * gb_view_source_class_init:
 * @klass: (in): A #GbViewSourceClass.
 *
 * Initializes the #GbViewSourceClass and prepares the vtable.
 */
static void
gb_view_source_class_init (GbViewSourceClass *klass)
{
    GbViewClass *view_class;
    GObjectClass *object_class;
    GtkWidgetClass *widget_class;
    GtkSourceStyleSchemeManager *schemes;

    object_class = G_OBJECT_CLASS(klass);
    object_class->finalize = gb_view_source_finalize;
    object_class->get_property = gb_view_source_get_property;
    object_class->set_property = gb_view_source_set_property;
    g_type_class_add_private(object_class, sizeof(GbViewSourcePrivate));

    widget_class = GTK_WIDGET_CLASS(klass);
    widget_class->grab_focus = gb_view_source_grab_focus;
    widget_class->style_set = gb_view_source_style_set;

    view_class = GB_VIEW_CLASS(klass);
    view_class->is_file = gb_view_source_is_file;
    view_class->save = gb_view_source_save;

    /**
     * GbViewSource:buffer:
     *
     * The "buffer" property is the #GtkSourceBuffer being visualized by
     * the editor.
     */
    gParamSpecs[PROP_BUFFER] =
        g_param_spec_object("buffer",
                            _("Buffer"),
                            _("The text buffer."),
                            GTK_SOURCE_TYPE_BUFFER,
                            G_PARAM_READABLE);
    g_object_class_install_property(object_class, PROP_BUFFER,
                                    gParamSpecs[PROP_BUFFER]);

    /**
     * GbViewSource:file:
     *
     * The "file" property is a #GFile that represents the target path.
     */
    gParamSpecs[PROP_FILE] =
        g_param_spec_object("file",
                            _("File"),
                            _("A GFile to display."),
                            G_TYPE_FILE,
                            G_PARAM_READWRITE);
    g_object_class_install_property(object_class, PROP_FILE,
                                    gParamSpecs[PROP_FILE]);

    /**
     * GbViewSource:path:
     *
     * The "path" property is the path to the destination file.
     */
    gParamSpecs[PROP_PATH] =
        g_param_spec_string("path",
                            _("Path"),
                            _("The path of the file."),
                            NULL,
                            G_PARAM_READABLE);
    g_object_class_install_property(object_class, PROP_PATH,
                                    gParamSpecs[PROP_PATH]);

    /**
     * GbViewSource:source-view:
     *
     * The "source-view" property is the #GtkSourceView widget.
     */
    gParamSpecs[PROP_SOURCE_VIEW] =
        g_param_spec_object("source-view",
                            _("Source View"),
                            _("The GtkSourceView widget."),
                            GTK_SOURCE_TYPE_VIEW,
                            G_PARAM_READABLE);
    g_object_class_install_property(object_class, PROP_SOURCE_VIEW,
                                    gParamSpecs[PROP_SOURCE_VIEW]);

    /**
     * GbViewSource::pre-save:
     *
     * The "pre-save" signal is emitted before saving a buffer.
     */
    gSignals[PRE_SAVE] = g_signal_new("pre-save",
                                      GB_TYPE_VIEW_SOURCE,
                                      G_SIGNAL_RUN_LAST,
                                      0,
                                      NULL,
                                      NULL,
                                      g_cclosure_marshal_VOID__VOID,
                                      G_TYPE_NONE,
                                      0);

    /*
     * Add search paths for our custom style schemes.
     */
    schemes = gtk_source_style_scheme_manager_get_default();
    gtk_source_style_scheme_manager_prepend_search_path(
        schemes, PACKAGE_DATA_DIR"/data/schemes");
    gtk_source_style_scheme_manager_prepend_search_path(schemes, "data/schemes");
}