~ubuntu-branches/ubuntu/precise/libappindicator/precise

« back to all changes in this revision

Viewing changes to src/app-indicator.c

  • Committer: Package Import Robot
  • Author(s): Ted Gould
  • Date: 2012-02-03 15:04:46 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120203150446-71egocdfmpgg2lk2
Tags: 0.4.90-0ubuntu1
* New upstream release.
  * Fix include with Dbusmenu 0.5.90
  * Fix GTK3 include paths in pkgconfig file (LP: #869373)
  * Add title property (LP: #923971)
  * Don't specify pyglib-2.0-python2.6 in LDFLAGS
  * fix fallback icon of the GtkStatusIcon (LP: #820080)
* debian/control: Dbusmneu Dep to 0.5.90
* deibna/*symbols: Updated to add [set|get]_title functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
        GtkWidget            *sec_activate_target;
79
79
        gboolean              sec_activate_enabled;
80
80
        guint32               ordering_index;
 
81
        gchar *               title;
81
82
        gchar *               label;
82
83
        gchar *               label_guide;
83
84
        gchar *               accessible_desc;
127
128
        PROP_LABEL,
128
129
        PROP_LABEL_GUIDE,
129
130
        PROP_ORDERING_INDEX,
130
 
        PROP_DBUS_MENU_SERVER
 
131
        PROP_DBUS_MENU_SERVER,
 
132
        PROP_TITLE
131
133
};
132
134
 
133
135
/* The strings so that they can be slowly looked up. */
144
146
#define PROP_LABEL_GUIDE_S           "label-guide"
145
147
#define PROP_ORDERING_INDEX_S        "ordering-index"
146
148
#define PROP_DBUS_MENU_SERVER_S      "dbus-menu-server"
 
149
#define PROP_TITLE_S                 "title"
147
150
 
148
151
/* Private macro, shhhh! */
149
152
#define APP_INDICATOR_GET_PRIVATE(o) \
251
254
                                                              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
252
255
 
253
256
        /**
254
 
         * AppIndicator:
 
257
         * AppIndicator:status:
255
258
         *
256
259
         * Whether the indicator is shown or requests attention. Defaults to
257
260
         * 'Passive'.
410
413
                                                             "DBusmenu server which is available for testing the application indicators.",
411
414
                                                             DBUSMENU_TYPE_SERVER,
412
415
                                                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
416
        /**
 
417
         * AppIndicator:title:
 
418
         *
 
419
         * Provides a way to refer to this application indicator in a human
 
420
         * readable form.  This is used in the Unity desktop in the HUD as
 
421
         * the first part of the menu entries to distinguish them from the
 
422
         * focused application's entries.
 
423
         */
 
424
        g_object_class_install_property(object_class,
 
425
                                        PROP_TITLE,
 
426
                                        g_param_spec_string (PROP_TITLE_S,
 
427
                                                             "Title of the application indicator",
 
428
                                                             "A human readable way to refer to this application indicator in the UI.",
 
429
                                                             NULL,
 
430
                                                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
413
431
 
414
432
        /* Signals */
415
433
 
575
593
        priv->menu = NULL;
576
594
        priv->menuservice = NULL;
577
595
        priv->ordering_index = 0;
 
596
        priv->title = NULL;
578
597
        priv->label = NULL;
579
598
        priv->label_guide = NULL;
580
599
        priv->label_change_idle = 0;
716
735
                priv->icon_theme_path = NULL;
717
736
        }
718
737
        
 
738
        if (priv->title != NULL) {
 
739
                g_free(priv->title);
 
740
                priv->title = NULL;
 
741
        }
 
742
 
719
743
        if (priv->label != NULL) {
720
744
                g_free(priv->label);
721
745
                priv->label = NULL;
830
854
                  gchar * oldlabel = priv->label;
831
855
                  priv->label = g_value_dup_string(value);
832
856
 
833
 
                  if (g_strcmp0(oldlabel, priv->label) != 0) {
834
 
                    signal_label_change(APP_INDICATOR(object));
835
 
                  }
836
 
 
837
857
                  if (priv->label != NULL && priv->label[0] == '\0') {
838
858
                        g_free(priv->label);
839
859
                        priv->label = NULL;
840
860
                  }
841
861
 
 
862
                  if (g_strcmp0(oldlabel, priv->label) != 0) {
 
863
                    signal_label_change(APP_INDICATOR(object));
 
864
                  }
 
865
 
842
866
                  if (oldlabel != NULL) {
843
867
                        g_free(oldlabel);
844
868
                  }
845
869
                  break;
846
870
                }
 
871
                case PROP_TITLE: {
 
872
                  gchar * oldtitle = priv->title;
 
873
                  priv->title = g_value_dup_string(value);
 
874
 
 
875
                  if (priv->title != NULL && priv->title[0] == '\0') {
 
876
                        g_free(priv->title);
 
877
                        priv->title = NULL;
 
878
                  }
 
879
 
 
880
                  if (g_strcmp0(oldtitle, priv->title) != 0 && self->priv->connection != NULL) {
 
881
                        GError * error = NULL;
 
882
 
 
883
                        g_dbus_connection_emit_signal(self->priv->connection,
 
884
                                                                                  NULL,
 
885
                                                                                  self->priv->path,
 
886
                                                                                  NOTIFICATION_ITEM_DBUS_IFACE,
 
887
                                                                                  "NewTitle",
 
888
                                                                                  NULL,
 
889
                                                                                  &error);
 
890
 
 
891
                        if (error != NULL) {
 
892
                                g_warning("Unable to send signal for NewTitle: %s", error->message);
 
893
                                g_error_free(error);
 
894
                        }
 
895
                  }
 
896
 
 
897
                  if (oldtitle != NULL) {
 
898
                        g_free(oldtitle);
 
899
                  }
 
900
                  break;
 
901
                }
847
902
                case PROP_LABEL_GUIDE: {
848
903
                  gchar * oldguide = priv->label_guide;
849
904
                  priv->label_guide = g_value_dup_string(value);
956
1011
                        g_value_set_object(value, priv->menuservice);
957
1012
                        break;
958
1013
 
 
1014
                case PROP_TITLE:
 
1015
                        g_value_set_string(value, priv->title);
 
1016
                        break;
 
1017
 
959
1018
        default:
960
1019
          G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
961
1020
          break;
1062
1121
                return g_variant_new_string(priv->icon_name ? priv->icon_name : "");
1063
1122
        } else if (g_strcmp0(property, "AttentionIconName") == 0) {
1064
1123
                return g_variant_new_string(priv->attention_icon_name ? priv->attention_icon_name : "");
 
1124
        } else if (g_strcmp0(property, "Title") == 0) {
 
1125
                return g_variant_new_string(priv->title ? priv->title : "");
1065
1126
        } else if (g_strcmp0(property, "IconThemePath") == 0) {
1066
1127
                return g_variant_new_string(priv->icon_theme_path ? priv->icon_theme_path : "");
1067
1128
        } else if (g_strcmp0(property, "Menu") == 0) {
2127
2188
}
2128
2189
 
2129
2190
/**
 
2191
 * app_indicator_set_title:
 
2192
 * @self: The #AppIndicator
 
2193
 * @title: (allow-none): Title of the app indicator
 
2194
 *
 
2195
 * Sets the title of the application indicator, or how it should be referred
 
2196
 * in a human readable form.  This string should be UTF-8 and localized as it
 
2197
 * expected that users will set it.
 
2198
 *
 
2199
 * In the Unity desktop the most prominent place that this is show will be
 
2200
 * in the HUD.  HUD listings for this application indicator will start with
 
2201
 * the title as the first part of the line for the menu items.
 
2202
 *
 
2203
 * Setting @title to %NULL removes the title.
 
2204
 */
 
2205
void
 
2206
app_indicator_set_title (AppIndicator *self, const gchar * title)
 
2207
{
 
2208
        g_return_if_fail (IS_APP_INDICATOR (self));
 
2209
 
 
2210
        g_object_set(G_OBJECT(self),
 
2211
                     PROP_TITLE_S, title == NULL ? "": title,
 
2212
                     NULL);
 
2213
 
 
2214
        return;
 
2215
}
 
2216
 
 
2217
/**
2130
2218
 * app_indicator_get_id:
2131
2219
 * @self: The #AppIndicator object to use
2132
2220
 *
2255
2343
}
2256
2344
 
2257
2345
/**
 
2346
 * app_indicator_get_title:
 
2347
 * @self: The #AppIndicator object to use
 
2348
 *
 
2349
 * Gets the title of the application indicator.  See the function
 
2350
 * app_indicator_set_title() for information on the title.
 
2351
 *
 
2352
 * Return value: The current title.
 
2353
 */
 
2354
const gchar *
 
2355
app_indicator_get_title (AppIndicator *self)
 
2356
{
 
2357
        g_return_val_if_fail (IS_APP_INDICATOR (self), NULL);
 
2358
 
 
2359
        return self->priv->title;
 
2360
}
 
2361
 
 
2362
 
 
2363
/**
2258
2364
 * app_indicator_get_menu:
2259
2365
 * @self: The #AppIndicator object to use
2260
2366
 *