]> Dogcows Code - chaz/openbox/blobdiff - openbox/config.c
more using g_slice_new() instead of g_new()
[chaz/openbox] / openbox / config.c
index 304079c96afde1f08a2162e0c8edfcef424b95f0..94ff1d7c8ad34b46358ac335fb57045b53fe5ef9 100644 (file)
@@ -94,9 +94,8 @@ guint    config_menu_hide_delay;
 gboolean config_menu_middle;
 guint    config_submenu_show_delay;
 guint    config_submenu_hide_delay;
-gboolean config_menu_client_list_icons;
 gboolean config_menu_manage_desktops;
-gboolean config_menu_user_show_icons;
+gboolean config_menu_show_icons;
 
 GSList *config_menu_files;
 
@@ -107,7 +106,7 @@ GSList *config_per_app_settings;
 
 ObAppSettings* config_create_app_settings(void)
 {
-    ObAppSettings *settings = g_new0(ObAppSettings, 1);
+    ObAppSettings *settings = g_slice_new0(ObAppSettings);
     settings->type = -1;
     settings->decor = -1;
     settings->shade = -1;
@@ -150,7 +149,7 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
         dst->pos_given = TRUE;
         dst->pos_force = src->pos_force;
         dst->position = src->position;
-        dst->monitor = src->monitor;
+        /* monitor is copied above */
     }
 }
 
@@ -201,8 +200,10 @@ static void config_parse_gravity_coord(xmlNodePtr node, GravityCoord *c)
 static void parse_per_app_settings(xmlNodePtr node, gpointer d)
 {
     xmlNodePtr app = obt_xml_find_node(node->children, "application");
-    gchar *name = NULL, *class = NULL, *role = NULL, *type = NULL;
-    gboolean name_set, class_set, type_set;
+    gchar *name = NULL, *class = NULL, *role = NULL, *title = NULL,
+        *type_str = NULL;
+    gboolean name_set, class_set, type_set, role_set, title_set;
+    ObClientType type;
     gboolean x_pos_given;
 
     while (app) {
@@ -210,10 +211,35 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
 
         class_set = obt_xml_attr_string(app, "class", &class);
         name_set = obt_xml_attr_string(app, "name", &name);
-        type_set = obt_xml_attr_string(app, "type", &type);
-        if (class_set || name_set) {
+        type_set = obt_xml_attr_string(app, "type", &type_str);
+        role_set = obt_xml_attr_string(app, "role", &role);
+        title_set = obt_xml_attr_string(app, "title", &title);
+
+        /* validate the type tho */
+        if (type_set) {
+            if (!g_ascii_strcasecmp(type_str, "normal"))
+                type = OB_CLIENT_TYPE_NORMAL;
+            else if (!g_ascii_strcasecmp(type_str, "dialog"))
+                type = OB_CLIENT_TYPE_DIALOG;
+            else if (!g_ascii_strcasecmp(type_str, "splash"))
+                type = OB_CLIENT_TYPE_SPLASH;
+            else if (!g_ascii_strcasecmp(type_str, "utility"))
+                type = OB_CLIENT_TYPE_UTILITY;
+            else if (!g_ascii_strcasecmp(type_str, "menu"))
+                type = OB_CLIENT_TYPE_MENU;
+            else if (!g_ascii_strcasecmp(type_str, "toolbar"))
+                type = OB_CLIENT_TYPE_TOOLBAR;
+            else if (!g_ascii_strcasecmp(type_str, "dock"))
+                type = OB_CLIENT_TYPE_DOCK;
+            else if (!g_ascii_strcasecmp(type_str, "desktop"))
+                type = OB_CLIENT_TYPE_DESKTOP;
+            else
+                type_set = FALSE; /* not valid! */
+        }
+
+        if (class_set || name_set || role_set || title_set || type_set) {
             xmlNodePtr n, c;
-            ObAppSettings *settings = config_create_app_settings();;
+            ObAppSettings *settings = config_create_app_settings();
 
             if (name_set)
                 settings->name = g_pattern_spec_new(name);
@@ -221,28 +247,15 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
             if (class_set)
                 settings->class = g_pattern_spec_new(class);
 
-            if (type_set) {
-                if (!g_ascii_strcasecmp(type, "normal"))
-                    settings->type = OB_CLIENT_TYPE_NORMAL;
-                else if (!g_ascii_strcasecmp(type, "dialog"))
-                    settings->type = OB_CLIENT_TYPE_DIALOG;
-                else if (!g_ascii_strcasecmp(type, "splash"))
-                    settings->type = OB_CLIENT_TYPE_SPLASH;
-                else if (!g_ascii_strcasecmp(type, "utility"))
-                    settings->type = OB_CLIENT_TYPE_UTILITY;
-                else if (!g_ascii_strcasecmp(type, "menu"))
-                    settings->type = OB_CLIENT_TYPE_MENU;
-                else if (!g_ascii_strcasecmp(type, "toolbar"))
-                    settings->type = OB_CLIENT_TYPE_TOOLBAR;
-                else if (!g_ascii_strcasecmp(type, "dock"))
-                    settings->type = OB_CLIENT_TYPE_DOCK;
-                else if (!g_ascii_strcasecmp(type, "desktop"))
-                    settings->type = OB_CLIENT_TYPE_DESKTOP;
-            }
-
-            if (obt_xml_attr_string(app, "role", &role))
+            if (role_set)
                 settings->role = g_pattern_spec_new(role);
 
+            if (title_set)
+                settings->title = g_pattern_spec_new(title);
+
+            if (type_set)
+                settings->type = type;
+
             if ((n = obt_xml_find_node(app->children, "decor")))
                 if (!obt_xml_node_contains(n, "default"))
                     settings->decor = obt_xml_node_bool(n);
@@ -340,11 +353,12 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
                 }
 
             config_per_app_settings = g_slist_append(config_per_app_settings,
-                                              (gpointer) settings);
+                                                     (gpointer) settings);
             g_free(name);
             g_free(class);
             g_free(role);
-            name = class = role = NULL;
+            g_free(title);
+            name = class = role = title = NULL;
         }
 
         app = obt_xml_find_node(app->next, "application");
@@ -817,17 +831,14 @@ static void parse_menu(xmlNodePtr node, gpointer d)
         config_submenu_show_delay = obt_xml_node_int(n);
     if ((n = obt_xml_find_node(node, "submenuHideDelay")))
         config_submenu_hide_delay = obt_xml_node_int(n);
-    if ((n = obt_xml_find_node(node, "applicationIcons")))
-        config_menu_client_list_icons = obt_xml_node_bool(n);
     if ((n = obt_xml_find_node(node, "manageDesktops")))
         config_menu_manage_desktops = obt_xml_node_bool(n);
     if ((n = obt_xml_find_node(node, "showIcons"))) {
-        config_menu_user_show_icons = obt_xml_node_bool(n);
-        #ifndef USE_IMLIB2
-        if (config_menu_user_show_icons)
-            g_message(_("Openbox was compiled without Imlib2."
-                      " Icons in user-defined menus will NOT be loaded."));
-        #endif
+        config_menu_show_icons = obt_xml_node_bool(n);
+#ifndef USE_IMLIB2
+        if (config_menu_show_icons)
+            g_message(_("Openbox was compiled without Imlib2 image loading support. Icons in menus will not be loaded."));
+#endif
     }
 
     while ((node = obt_xml_find_node(node, "file"))) {
@@ -974,6 +985,8 @@ void config_startup(ObtXmlInst *i)
     config_font_inactivewindow = NULL;
     config_font_menuitem = NULL;
     config_font_menutitle = NULL;
+    config_font_activeosd = NULL;
+    config_font_inactiveosd = NULL;
 
     obt_xml_register(i, "theme", parse_theme, NULL);
 
@@ -1031,10 +1044,9 @@ void config_startup(ObtXmlInst *i)
     config_menu_middle = FALSE;
     config_submenu_show_delay = 200;
     config_submenu_hide_delay = 400;
-    config_menu_client_list_icons = TRUE;
     config_menu_manage_desktops = TRUE;
     config_menu_files = NULL;
-    config_menu_user_show_icons = TRUE;
+    config_menu_show_icons = TRUE;
 
     obt_xml_register(i, "menu", parse_menu, NULL);
 
@@ -1070,8 +1082,9 @@ void config_shutdown(void)
         ObAppSettings *itd = (ObAppSettings *)it->data;
         if (itd->name)  g_pattern_spec_free(itd->name);
         if (itd->role)  g_pattern_spec_free(itd->role);
+        if (itd->title) g_pattern_spec_free(itd->title);
         if (itd->class) g_pattern_spec_free(itd->class);
-        g_free(it->data);
+        g_slice_free(ObAppSettings, it->data);
     }
     g_slist_free(config_per_app_settings);
 }
This page took 0.027801 seconds and 4 git commands to generate.