Example #1
0
// We don't need that stupid 'gtk-entry-select-on-focus' stuff.
// So we redefine 'grab_focus'.
static void midorator_entry_grab_focus_cb(GtkWidget *w) {
	gboolean old;
	g_object_get(gtk_settings_get_default(), "gtk-entry-select-on-focus", &old, NULL);
	g_object_set(gtk_settings_get_default(), "gtk-entry-select-on-focus", FALSE, NULL);
	MIDORATOR_ENTRY_GET_CLASS(w)->old_grab_focus(w);
	g_object_set(gtk_settings_get_default(), "gtk-entry-select-on-focus", old, NULL);
}
/*
 * FIXME: make this bullet proof wrt uri scheme.
 */
static char *
url (GSList const	*args,
     void		*user_data)
{
	char		*resolved_path;
	char		*ret;
#ifdef CCSS_WITH_SOUP
	char		*given_path;
	SoupURI		*uri;

	g_return_val_if_fail (args, NULL);

	given_path = g_strdup_printf ("file:///%s", (char const *) args->data);
	uri = soup_uri_new (given_path);
	g_free (given_path), given_path = NULL;

	resolved_path = gtk_rc_find_pixmap_in_path (gtk_settings_get_default (), NULL, uri->path);
	soup_uri_set_path (uri, resolved_path);
	g_free (resolved_path), resolved_path = NULL;

	ret = soup_uri_to_string (uri, false);
	soup_uri_free (uri), uri = NULL;
#else
	char const *given_path;

	g_return_val_if_fail (args, NULL);

	given_path = (char const *) args->data;
	resolved_path = gtk_rc_find_pixmap_in_path (gtk_settings_get_default (), NULL, given_path);
	ret = g_strdup_printf ("file:///%s", resolved_path);
	g_free (resolved_path), resolved_path = NULL;
#endif

	return ret;
}
int iupdrvSetGlobal(const char *name, const char *value)
{
  if (iupStrEqual(name, "INPUTCALLBACKS"))
  {
    if (iupStrBoolean(value))
      gdk_event_handler_set(iGdkEventFunc, NULL, NULL);
    else 
      gdk_event_handler_set((GdkEventFunc)gtk_main_do_event, NULL, NULL);
    return 1;
  }
  if (iupStrEqual(name, "UTF8MODE"))
  {
    iupgtkStrSetUTF8Mode(iupStrBoolean(value));
    return 1;
  }
  if (iupStrEqual(name, "UTF8AUTOCONVERT"))
  {
    iupgtkStrSetUTF8Mode(!iupStrBoolean(value));
    return 0;
  }
  if (iupStrEqual(name, "SHOWMENUIMAGES"))
  {
#if !GTK_CHECK_VERSION(3, 10, 0)  /* deprecated since 3.10 */
    /* make sure the type is realized */
    g_type_class_unref (g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM));
#endif

    if (iupStrBoolean(value))
      g_object_set (gtk_settings_get_default (), "gtk-menu-images", TRUE, NULL);
    else
      g_object_set (gtk_settings_get_default (), "gtk-menu-images", FALSE, NULL);
  }
  return 1;
}
Example #4
0
/** Reads an integer from the GTK default settings registry
 * (see http://library.gnome.org/devel/gtk/stable/GtkSettings.html).
 * @param property_name The property to read.
 * @param default_value The default value in case the value could not be read.
 * @return The value for the property if it exists, otherwise the @a default_value.
 */
gint ui_get_gtk_settings_integer(const gchar *property_name, gint default_value)
{
	if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(
		gtk_settings_get_default())), property_name))
	{
		gint value;
		g_object_get(G_OBJECT(gtk_settings_get_default()), property_name, &value, NULL);
		return value;
	}
	else
		return default_value;
}
Example #5
0
static void override_menu_key(void)
{
	if (gtk_menu_key_accel == NULL) /* for restoring the default value */
		g_object_get(G_OBJECT(gtk_settings_get_default()),
			"gtk-menu-bar-accel", &gtk_menu_key_accel, NULL);

	if (vc->ignore_menu_bar_accel)
		gtk_settings_set_string_property(gtk_settings_get_default(),
			"gtk-menu-bar-accel", "<Shift><Control><Mod1><Mod2><Mod3><Mod4><Mod5>F10", "Geany");
	else
		gtk_settings_set_string_property(gtk_settings_get_default(),
			"gtk-menu-bar-accel", gtk_menu_key_accel, "Geany");
}
Example #6
0
static void GlobalGL_sharedContextCreated (void)
{
	// report OpenGL information
	globalOutputStream() << "GL_VENDOR: " << reinterpret_cast<const char*> (glGetString(GL_VENDOR)) << "\n";
	globalOutputStream() << "GL_RENDERER: " << reinterpret_cast<const char*> (glGetString(GL_RENDERER)) << "\n";
	globalOutputStream() << "GL_VERSION: " << reinterpret_cast<const char*> (glGetString(GL_VERSION)) << "\n";
	globalOutputStream() << "GL_EXTENSIONS: " << reinterpret_cast<const char*> (glGetString(GL_EXTENSIONS)) << "\n";

	QGL_sharedContextCreated(GlobalOpenGL());

	GlobalShaderCache().realise();
	GlobalTexturesCache().realise();

	/* use default font here (Sans 10 is gtk default) */
	GtkSettings *settings = gtk_settings_get_default();
	gchar* fontname;
	g_object_get(settings, "gtk-font-name", &fontname, (char*) 0);
	g_font = glfont_create(fontname);
	// Fallbacks
	if (g_font.getPixelHeight() == -1)
		g_font = glfont_create("Sans 10");
	if (g_font.getPixelHeight() == -1)
		g_font = glfont_create("fixed 10");
	if (g_font.getPixelHeight() == -1)
		g_font = glfont_create("courier new 10");

	GlobalOpenGL().m_font = g_font.getDisplayList();
	GlobalOpenGL().m_fontHeight = g_font.getPixelHeight();
}
Example #7
0
GtkWidget *get_language_menu(GtkWidget *window, cb_t cb)
{
    //GtkAccelGroup *group;
    gint i;

    //group = gtk_accel_group_new ();
    lang_menu = gtk_image_menu_item_new();

    for (i = 0; i < NUM_LANGS; i++) {
        flags[i] = get_picture(flags_files[i]);
        g_object_ref(flags[i]);
    }

    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(lang_menu), flags[language]);        
    gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(lang_menu), TRUE);

    g_signal_connect(G_OBJECT(lang_menu), "button_press_event",
      G_CALLBACK(lang_dialog), cb);

    set_gui_language(language);

    g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL);

    return lang_menu;
}
inline char* get_icon_theme_name()
{
    GtkSettings* gs = gtk_settings_get_default();
    char* name = NULL;
    g_object_get(gs, "gtk-icon-theme-name", &name, NULL);
    return name;
}
Example #9
0
bool wxApp::SetNativeTheme(const wxString& theme)
{
#ifdef __WXGTK3__
    wxUnusedVar(theme);
    return false;
#else
    wxString path;
    path = gtk_rc_get_theme_dir();
    path += "/";
    path += theme.utf8_str();
    path += "/gtk-2.0/gtkrc";

    if ( wxFileExists(path.utf8_str()) )
        gtk_rc_add_default_file(path.utf8_str());
    else if ( wxFileExists(theme.utf8_str()) )
        gtk_rc_add_default_file(theme.utf8_str());
    else
    {
        wxLogWarning("Theme \"%s\" not available.", theme);

        return false;
    }

    gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);

    return true;
#endif
}
Example #10
0
/* compose_get_font */
static char const * _compose_get_font(Compose * compose)
{
	char const * p;
	char * q;
	GtkSettings * settings;
	PangoFontDescription * desc;

	if((p = config_get(compose->config, NULL, "messages_font")) != NULL)
		return p;
	settings = gtk_settings_get_default();
	g_object_get(G_OBJECT(settings), "gtk-font-name", &q, NULL);
	if(q != NULL)
	{
		desc = pango_font_description_from_string(q);
		g_free(q);
		pango_font_description_set_family(desc, "monospace");
		q = pango_font_description_to_string(desc);
		config_set(compose->config, NULL, "messages_font", q);
		g_free(q);
		pango_font_description_free(desc);
		if((p = config_get(compose->config, NULL, "messages_font"))
				!= NULL)
			return p;
	}
	return MAILER_MESSAGES_FONT;
}
Example #11
0
static EIF_POINTER inline_F24_244 (void)
{
	#if GTK_MAJOR_VERSION > 1
	return gtk_settings_get_default();
#endif
	;
}
Example #12
0
G_MODULE_EXPORT gboolean
gw_window_focus_in_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
{
    //Declarations
    GwWindow *window;
    GwApplication *application;
    GMenuModel *menumodel;
    gboolean os_shows_win_menu;
    GtkSettings *settings;
    
    //Initializations
    window = GW_WINDOW (widget);
    application = gw_window_get_application (window);
    settings = gtk_settings_get_default ();
    g_object_get (settings, "gtk-shell-shows-menubar", &os_shows_win_menu, NULL);

    menumodel = gw_window_get_transient_for_menumodel (window);
    if (menumodel == NULL)
      menumodel = G_MENU_MODEL (g_menu_new ());
    if (menumodel == NULL) 
      return FALSE;

    if (os_shows_win_menu)
      gw_application_set_win_menubar (GW_APPLICATION (application), menumodel);

    return FALSE;
}
Example #13
0
static void
set_palette(void)
{
  GtkWidget *sel;
  int n;
  GdkColor *colors;
  GtkSettings *settings;

  if (Menulocal.Palette == NULL) {
    return;
  }

  settings = gtk_settings_get_default();
  if (settings == NULL) {
    return;
  }

  sel = gtk_color_selection_new();
  if (gtk_color_selection_palette_from_string(Menulocal.Palette, &colors, &n)) {
    g_free(colors);
    g_object_set(settings, "gtk-color-palette", Menulocal.Palette, NULL);
  }
  gtk_widget_destroy(sel);

  return;
}
Example #14
0
void pApplication::initialize() {
  display = XOpenDisplay(nullptr);

  settings = new Settings;
  settings->load();

  int argc = 1;
  char* argv[] = {new char[8], nullptr};
  strcpy(argv[0], "phoenix");
  char** argvp = argv;
  gtk_init(&argc, &argvp);

  GtkSettings* gtkSettings = gtk_settings_get_default();
//g_object_set(gtkSettings, "gtk-button-images", true, nullptr);

  gtk_rc_parse_string(R"(
    style "phoenix-gtk"
    {
      GtkWindow::resize-grip-width = 0
      GtkWindow::resize-grip-height = 0
      GtkTreeView::vertical-separator = 0
      GtkComboBox::appears-as-list = 1
    }
    class "GtkWindow" style "phoenix-gtk"
    class "GtkTreeView" style "phoenix-gtk"
  # class "GtkComboBox" style "phoenix-gtk"
  )");

  pKeyboard::initialize();
}
Example #15
0
File: prefs.c Project: Cw1X/pnmixer
void load_prefs(void) {
  GError* err = NULL;
  gchar* filename = g_strconcat(g_get_user_config_dir(), "/pnmixer/config", NULL);
  gchar *default_theme_name;
  GtkSettings *settings;

  if (keyFile != NULL)
    g_key_file_free(keyFile);
  keyFile = g_key_file_new();
  if (g_file_test(filename,G_FILE_TEST_EXISTS)) {
    if (!g_key_file_load_from_file(keyFile,filename,0,&err)) {
      report_error(_("\nCouldn't load preferences file: %s\n"), err->message);
      g_error_free(err);
      g_key_file_free(keyFile);
      keyFile = NULL;
    }
  }
  else {
    if (!g_key_file_load_from_data(keyFile,DEFAULT_PREFS,strlen(DEFAULT_PREFS),0,&err)) {
      report_error(_("\nCouldn't load default preferences: %s\n"), err->message);
      g_error_free(err);
      g_key_file_free(keyFile);
      keyFile = NULL;
    }
    settings = gtk_settings_get_default();
    g_object_get(settings,"gtk-icon-theme-name",&default_theme_name,NULL);
    g_key_file_set_string(keyFile,"PNMixer","IconTheme",default_theme_name);
    g_free(default_theme_name);
  }
  g_free(filename);
}
int
main (int argc, char **argv)
{
        gchar *new_default_files[1] = {NULL};
	GtkSettings *settings;
	gint i;
	gtk_init (&argc, &argv);
        
        /* we get a gtkrc from GTK2_RC_FILES, remove the users theme ... */
        settings = gtk_settings_get_default ();
        g_object_set (settings, "gtk-theme-name", "Raleigh", NULL);
        
	create_testwidgets ();

	window = gtk_window_new (GTK_WINDOW_POPUP);
	box = gtk_vbox_new (FALSE, 0);
	
	gtk_container_add ((GtkContainer*)window, box);
	
	for (i = 0; i < WIDGET_COUNT; i++) {
		if (widgets[i] && !widgets[i]->parent)
			gtk_box_pack_end (GTK_BOX (box), widgets[i], FALSE, FALSE, 0);
	}

	while (gdk_events_pending ())
		gtk_main_iteration_do (FALSE);
	
	gtk_widget_show_all (window);
	while (gdk_events_pending ())
		gtk_main_iteration_do (FALSE);
	
	for (i = 0; i < G_N_ELEMENTS (tests); i++)
		run_test (i);
	
	/* remove the rc file again. This should cause an unload of the engine
	 * and destruction of all engine objects. */
        gtk_rc_set_default_files (new_default_files);
	gtk_rc_reparse_all_for_settings (settings, TRUE);

	gtk_widget_hide (window);
	gtk_widget_unmap (window);

	while (gdk_events_pending ())
		gtk_main_iteration_do (FALSE);

	gtk_widget_destroy (window);

	while (gdk_events_pending ())
		gtk_main_iteration_do (FALSE);

	/* TODO: It would be really cool to check if there is no
	 * loaded engine at this point. */

	/*
	 * HRM: Calling the follwing causes an assertion failure inside cairo here -- 01.10.2010, Benjamin
	cairo_debug_reset_static_data ();
	*/

	return 0;
}
Example #17
0
//core theme class functions
Boolean MCNativeTheme::load()
{
	static Boolean initialised = False;

	if (!MCscreen -> hasfeature(PLATFORM_FEATURE_NATIVE_THEMES))
		return false;
	
	if (!initialised)
	{
		gtk_init();
		
		initialised = True;
		GtkSettings *settings = gtk_settings_get_default();
		if (settings)
			g_signal_connect_data( settings, "notify::gtk-theme-name", G_CALLBACK(reload_theme),
			                         NULL, NULL, (GConnectFlags)0);
	}
	gtkpix = NULL;
	mNeedNewGC = true;

	if (MCscreen)
	{
		MCColor tbackcolor;
		moz_gtk_get_widget_color(GTK_STATE_NORMAL,
		                         tbackcolor.red,tbackcolor.green,tbackcolor.blue) ;
		MCscreen->background_pixel = tbackcolor;//tcolor = zcolor;
		
		// MW-2012-01-27: [[ Bug 9511 ]] Set the hilite color based on the current GTK theme.
		MCColor thilitecolor;
		moz_gtk_get_widget_color(GTK_STATE_SELECTED, thilitecolor.red, thilitecolor.green, thilitecolor.blue);
		MChilitecolor = thilitecolor;
	}

	return true;
}
/**
 * static applet config functions
 */
static void
matekbd_indicator_config_load_font (MatekbdIndicatorConfig * ind_config)
{
    ind_config->font_family =
        g_settings_get_string (ind_config->settings,
                               MATEKBD_INDICATOR_CONFIG_KEY_FONT_FAMILY);

    if (ind_config->font_family == NULL ||
            ind_config->font_family[0] == '\0') {
        PangoFontDescription *fd = NULL;
        GtkStyle *style =
            gtk_rc_get_style_by_paths (gtk_settings_get_default (),
                                       GTK_STYLE_PATH,
                                       GTK_STYLE_PATH,
                                       GTK_TYPE_LABEL);
        if (style != NULL)
            fd = style->font_desc;
        if (fd != NULL) {
            ind_config->font_family =
                g_strdup (pango_font_description_to_string(fd));
        }
    }
    xkl_debug (150, "font: [%s]\n", ind_config->font_family);

}
Example #19
0
static gboolean
load_css_from_resource (GApplication *application,
                        GtkCssProvider *provider,
                        gboolean theme)
{
  const char *base_path;
  gs_free char *uri;
  gs_unref_object GFile *file;
  gs_free_error GError *error = NULL;

  base_path = g_application_get_resource_base_path (application);

  if (theme) {
    gs_free char *str, *theme_name;

    g_object_get (gtk_settings_get_default (), "gtk-theme-name", &str, NULL);
    theme_name = g_ascii_strdown (str, -1);
    uri = g_strdup_printf ("resource://%s/css/%s/terminal.css", base_path, theme_name);
  } else {
    uri = g_strdup_printf ("resource://%s/css/terminal.css", base_path);
  }

  file = g_file_new_for_uri (uri);
  if (!g_file_query_exists (file, NULL /* cancellable */))
    return FALSE;

  if (!gtk_css_provider_load_from_file (provider, file, &error))
    g_assert_no_error (error);

  return TRUE;
}
Example #20
0
 void updateTheme()
 {
     gchar* themeName = 0;
     g_object_get(gtk_settings_get_default(), "gtk-theme-name", &themeName, NULL);
     m_themeName = QString::fromUtf8(themeName);
     g_free(themeName);
 }
static ca_context*
ca_context_get_default()
{
    // This allows us to avoid race conditions with freeing the context by handing that
    // responsibility to Glib, and still use one context at a time
    static GStaticPrivate ctx_static_private = G_STATIC_PRIVATE_INIT;

    ca_context* ctx = (ca_context*) g_static_private_get(&ctx_static_private);

    if (ctx) {
        return ctx;
    }

    ca_context_create(&ctx);
    if (!ctx) {
        return nullptr;
    }

    g_static_private_set(&ctx_static_private, ctx, (GDestroyNotify) ca_context_destroy);

    GtkSettings* settings = gtk_settings_get_default();
    if (g_object_class_find_property(G_OBJECT_GET_CLASS(settings),
                                     "gtk-sound-theme-name")) {
        gchar* sound_theme_name = nullptr;
        g_object_get(settings, "gtk-sound-theme-name", &sound_theme_name, NULL);

        if (sound_theme_name) {
            ca_context_change_props(ctx, "canberra.xdg-theme.name", sound_theme_name, NULL);
            g_free(sound_theme_name);
        }
    }

    nsCOMPtr<nsIStringBundleService> bundleService =
        mozilla::services::GetStringBundleService();
    if (bundleService) {
        nsCOMPtr<nsIStringBundle> brandingBundle;
        bundleService->CreateBundle("chrome://branding/locale/brand.properties",
                                    getter_AddRefs(brandingBundle));
        if (brandingBundle) {
            nsAutoString wbrand;
            brandingBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
                                              getter_Copies(wbrand));
            NS_ConvertUTF16toUTF8 brand(wbrand);

            ca_context_change_props(ctx, "application.name", brand.get(), NULL);
        }
    }

    nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
    if (appInfo) {
        nsAutoCString version;
        appInfo->GetVersion(version);

        ca_context_change_props(ctx, "application.version", version.get(), NULL);
    }

    ca_context_change_props(ctx, "application.icon_name", MOZ_APP_NAME, NULL);

    return ctx;
}
Example #22
0
void RenderThemeGtk::systemFont(CSSValueID, FontDescription& fontDescription) const
{
    GtkSettings* settings = gtk_settings_get_default();
    if (!settings)
        return;

    // This will be a font selection string like "Sans 10" so we cannot use it as the family name.
    GUniqueOutPtr<gchar> fontName;
    g_object_get(settings, "gtk-font-name", &fontName.outPtr(), NULL);

    PangoFontDescription* pangoDescription = pango_font_description_from_string(fontName.get());
    if (!pangoDescription)
        return;

    fontDescription.setOneFamily(pango_font_description_get_family(pangoDescription));

    int size = pango_font_description_get_size(pangoDescription) / PANGO_SCALE;
    // If the size of the font is in points, we need to convert it to pixels.
    if (!pango_font_description_get_size_is_absolute(pangoDescription))
        size = size * (getScreenDPI() / 72.0);

    fontDescription.setSpecifiedSize(size);
    fontDescription.setIsAbsoluteSize(true);
    fontDescription.setGenericFamily(FontDescription::NoFamily);
    fontDescription.setWeight(FontWeightNormal);
    fontDescription.setItalic(false);
    pango_font_description_free(pangoDescription);
}
Example #23
0
static void set_app_font (const char *fontname)
{
    GtkSettings *settings;

    if (fontname != NULL && *fontname == 0) return;

    settings = gtk_settings_get_default();

    if (fontname == NULL) {
        g_object_set(G_OBJECT(settings), "gtk-font-name", appfontname, NULL);
    } else {
        GtkWidget *w;
        PangoFontDescription *pfd;
        PangoContext *pc;
        PangoFont *pfont;

        w = gtk_label_new(NULL);
        pfd = pango_font_description_from_string(fontname);
        pc = gtk_widget_get_pango_context(w);
        pfont = pango_context_load_font(pc, pfd);

        if (pfont != NULL) {
            strcpy(appfontname, fontname);
            g_object_set(G_OBJECT(settings), "gtk-font-name", appfontname,
                NULL);
        }

        gtk_widget_destroy(w);
        pango_font_description_free(pfd);
    }
}
Example #24
0
static void
cinnamon_fonts_init (void)
{
  GtkSettings *settings;

  /* Disable text mipmapping; it causes problems on pre-GEM Intel
   * drivers and we should just be rendering text at the right
   * size rather than scaling it. If we do effects where we dynamically
   * zoom labels, then we might want to reconsider.
   */
  clutter_set_font_flags (clutter_get_font_flags () & ~CLUTTER_FONT_MIPMAPPING);

  settings = gtk_settings_get_default ();
  g_object_connect (settings,
                    "signal::notify::gtk-xft-dpi",
                    G_CALLBACK (settings_notify_cb), NULL,
                    "signal::notify::gtk-xft-antialias",
                    G_CALLBACK (settings_notify_cb), NULL,
                    "signal::notify::gtk-xft-hinting",
                    G_CALLBACK (settings_notify_cb), NULL,
                    "signal::notify::gtk-xft-hintstyle",
                    G_CALLBACK (settings_notify_cb), NULL,
                    NULL);
  update_font_options (settings);
}
Example #25
0
int main(int argc, char **argv)
{
  set_is_chs();

  exec_setup_scripts();

  init_TableDir();

  load_settings();

  load_gtab_list(FALSE);

  gtk_init(&argc, &argv);



#if HIME_i18n_message
  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
  textdomain(GETTEXT_PACKAGE);
#endif

  g_object_get(gtk_settings_get_default(), "gtk-alternative-button-order", &button_order, NULL);

#if 0
  // once you invoke hime-setup, the left-right buton tips is disabled
  save_hime_conf_int(LEFT_RIGHT_BUTTON_TIPS, 0);
#endif

  run_dialog();
  gtk_main();
  return 0;
}
Example #26
0
static gboolean
gtk_application_impl_dbus_prefers_app_menu (GtkApplicationImpl *impl)
{
  static gboolean decided;
  static gboolean result;

  /* We do not support notifying if/when the result changes, so make
   * sure that once we give an answer, we will always give the same one.
   */
  if (!decided)
    {
      GtkSettings *gtk_settings;
      gboolean show_app_menu;
      gboolean show_menubar;

      gtk_settings = gtk_settings_get_default ();
      g_object_get (G_OBJECT (gtk_settings),
                    "gtk-shell-shows-app-menu", &show_app_menu,
                    "gtk-shell-shows-menubar", &show_menubar,
                    NULL);

      /* We prefer traditional menus when we have a shell that doesn't
       * show the appmenu or we have a shell that shows menubars
       * (ie: Unity)
       */
      result = show_app_menu && !show_menubar;
      decided = TRUE;
    }

  return result;
}
Example #27
0
static void
nautilus_application_init_actions (NautilusApplication *self)
{
	GtkBuilder *builder;
	GError *error = NULL;
	const gchar *debug_no_app_menu;

	g_action_map_add_action_entries (G_ACTION_MAP (self),
					 app_entries, G_N_ELEMENTS (app_entries),
					 self);
	gtk_application_add_accelerator (GTK_APPLICATION (self), "F10", "win.gear-menu", NULL);

	builder = gtk_builder_new ();
	gtk_builder_add_from_resource (builder, "/org/gnome/nautilus/nautilus-app-menu.ui", &error);

	if (error == NULL) {
		gtk_application_set_app_menu (GTK_APPLICATION (self),
					      G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
	} else {
		g_critical ("Unable to add the application menu: %s\n", error->message);
		g_error_free (error);
	}

	g_object_unref (builder);

	debug_no_app_menu = g_getenv ("NAUTILUS_DEBUG_NO_APP_MENU");
	if (debug_no_app_menu) {
		DEBUG ("Disabling app menu GtkSetting as requested...");
		g_object_set (gtk_settings_get_default (),
			      "gtk-shell-shows-app-menu", FALSE,
			      NULL);
	}
}
Example #28
0
static void 
gw_window_constructed (GObject *object)
{
    GwWindow *window;
    GwWindowPrivate *priv;
    gboolean os_shows_app_menu;
    GtkSettings *settings;

    //Chain the parent class
    {
      G_OBJECT_CLASS (gw_window_parent_class)->constructed (object);
    }

    window = GW_WINDOW (object);
    priv = window->priv;
    settings = gtk_settings_get_default ();
    g_object_get (settings, "gtk-shell-shows-app-menu", &os_shows_app_menu, NULL);
    gtk_widget_add_events (GTK_WIDGET (window), GDK_FOCUS_CHANGE_MASK);

    gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), FALSE);

    priv->accelgroup = gtk_accel_group_new ();
    gtk_window_add_accel_group (GTK_WINDOW (window), priv->accelgroup);
    gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (priv->application));
    priv->builder = gtk_builder_new ();
    gw_window_load_ui_xml (window, priv->ui_xml);
    priv->toplevel = GTK_WIDGET (gw_window_get_object (GW_WINDOW (window), "toplevel"));

    g_signal_connect (G_OBJECT (window), "configure-event", G_CALLBACK (gw_window_configure_event_cb), NULL);
    g_signal_connect (window, "focus-in-event", G_CALLBACK (gw_window_focus_in_event_cb), NULL);
}
Example #29
0
/**
 *  This function gets the dpi in the same way that mozilla gets the dpi, 
 *  this allows us to convert from pixels to points easily
 */
static gint
mozilla_get_dpi (void)
{
	GtkSettings* settings = gtk_settings_get_default ();
	gint dpi = 0;
	char *val;
	float screenWidthIn;

	/* Use the gtk-xft-dpi setting if it is set */
	if (g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (settings)),
					  "gtk-xft-dpi"))
	{
		g_object_get (G_OBJECT (settings), "gtk-xft-dpi", &dpi, NULL);
		if (dpi) return INT_ROUND (dpi / PANGO_SCALE);
	}

	/* Fall back to what xft thinks it is */
	val = XGetDefault (GDK_DISPLAY (), "Xft", "dpi");
	if (val)
	{
		char *e;
		double d = strtod(val, &e);
		if (e != val) return INT_ROUND (d);
	}
	
	/* Fall back to calculating manually from the gdk screen settings */
	screenWidthIn = ((float)gdk_screen_width_mm()) / 25.4f;
	return INT_ROUND (gdk_screen_width() / screenWidthIn);
}
Example #30
0
File: main.c Project: ekd123/ekode
gint 
main (gint argc,
      gchar * argv[])
{
    GtkSettings *settings;
    GtkWidget *window;

    gtk_init (&argc, &argv);

    /* create window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (window), "hello world");

    /* reset theme */
    settings = gtk_settings_get_default ();

    g_object_set (settings, "gtk-application-prefer-dark-theme", TRUE, NULL);

    /* show window */
    g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit),
                      NULL);
    gtk_widget_show_all (window);
    gtk_main ();
    return 0;
}